Linux basic commands-Bash command line tips you should know

Linux has a lot of commands, but most people only use a small part of them. The following introduces some of the most commonly used and basic Linux commands in the terminal.

First, we will introduce some tips to make the command line easier to use:

Use tabs for automatic completion. After you start typing in the Linux terminal, click tab, and it will suggest possible options, and it will prompt possible options starting with the string you are currently typing.

  • Use ctrl + r to search for commands you have used before.
  • Quickly move to the beginning or end with lines ctrl + a and ctrl + e .
  • Use to reuse the previous command in the current command !! .
  • You can use ; to separate commands to run multiple commands on one line.

It's time to learn common Linux commands. By using the man command, you can get more information about any of these commands. This will display the man page for the command. For example, if you type man cat in a Linux terminal, you will get more information about the cat command.

ls

Linux basic commands-Bash command line tips you should know

cd

Linux basic commands-Bash command line tips you should know

mv

Linux basic commands-Bash command line tips you should know

mkdir

rmdir

Delete empty directories.

touch

Create an empty file with the specified name.

rm

Delete files and / or directories.

locate

Target specific files.

clear

Clear the command line screen / window to start over.

cp

Copy files and directories.

alias

Create aliases for Linux commands.

Example: alias ggg = grep will allow you to use ggg instead of grep.

cat

Display the contents of the file on the screen.

chown

Change who owns the file.

chmod

Change file permissions.

sudo

Perform tasks that require administrative or root permissions.

find

Search for files that match the provided pattern. This command is used to search for files and folders using filters such as name, size, access time and modification time.

Linux basic commands-Bash command line tips you should know

grep

Search for specific strings or expressions in the file or output. This command searches for lines containing the specified pattern and writes them to standard output by default.

Linux basic commands-Bash command line tips you should know

date

Display or set the system date and time.

df

Displays reports on system disk space usage.

of

Shows how much space each file occupies. This will display the size in disk block numbers. If you want to view it in bytes, kilobytes and megabytes, please add the following -h parameter: du -h.

file

Determine the type of file.

Linux basic commands-Bash command line tips you should know

history

Display command history.

kill

Stop the process.

Example: Use the command to stop the process with PID 485 kill 485. Use the command below ps to determine the PID of the process.

less

View the file contents one page at a time.

ps

Displays a list of currently running processes. This can be used to determine the PID required for kill processing.

pwd

Displays the path name of the current directory. "Print Working Directory"

ssh

Log in to another Linux computer remotely via the network.

tail-displays the last 10 lines of the file. Use the -n (number) option to view fewer or more lines.

takes

Store and extract files from tarfile (.tar) or tarball (.tar.gz or .tgz).

top

Shows the resources being used on the system, similar to the task manager in Windows.

Linux basic commands-Bash command line tips you should know

Guess you like

Origin www.linuxidc.com/Linux/2020-04/162834.htm