Fortune Telling Collection - Comprehensive fortune-telling - What are the common linux commands?

What are the common linux commands?

Common Linux commands are:

Pwd command

Use the pwd command to find the path of the current working directory (folder). This command will return an absolute (complete) path, which is basically the path of all directories starting with/. An example of an absolute path is /home/username.

Cd command

To browse Linux files and directories, use the cd command. Depending on your current working directory, it needs the full path or name of the directory. Suppose you are in /home/username/Documents, and you want to go to the subdirectory Photos of the document. To do this, just type the following command: cd Photos. On the other hand, if you want to switch to a brand new directory, such as /home/username/Movies. In this case, you must enter a cd, and then enter the absolute path of the directory: cd /home/username/Movies. There are some shortcuts to help you navigate quickly: cd .. (with two dots) Move up a directory cd directly to the home folder cd- (with hyphens) Move to the previous directory By the way, Linux shell is case-sensitive. Therefore, you must enter the directory of the name accurately.

Ls command

The LS command is used to view the contents of the directory. By default, this command displays the contents of the current working directory. If you want to view the contents of another directory, type ls, and then type the path of that directory. For example, enter the LS/home/ user name/file of the content viewed by the document. You can use the ls command to use the following variants: ls -R will also list all files in subdirectories. Ls -a will display hidden files. Ls -al will list files and directories and detailed information, such as permissions, size, owner, etc.

Cat command

Cat (abbreviation of connection) is one of the most commonly used commands in Linux. It is used to list the contents of files in standard output (sdout). To run this command, type cat, and then enter the file name and its extension. For example: catfile.txt The following are other ways to use the cat command: cat & gtFilename creates a new file, catfilename 1filename2 >. Filename3 concatenates two files (1 and 2) and stores their outputs in a new file (3) converts the files to uppercase or lowercase, cat filename | tra-za-z > output.txt.

Cp command

Use the cp command to copy files from the current directory to another directory. For example, the CP scenery.jpg/home/username/Pictures command will create a copy of Scene.jpg in your picture directory (from the current directory).

Mv command

The main purpose of the mv command is to move files, although it can also be used to rename files. Parameters in mv are similar to cp commands. You need to enter the mv, file name and destination directory. For example: MV file.txt/home/username/documents.

Mkdir command

Use the mkdir command to create a new directory-if you type mkdir Music, it will create a directory named Music. There are some additional mkdir commands: to generate a new directory in another directory, you can use this basic Linux command mkdir Music/Newfile to create a directory between two existing directories through the p (parent) option. For example, mkdir -p Music/2022/Newfile will create a new "2022" file.

Rmdir command

If you need to delete a directory, use the rmdir command. However, rmdir only allows you to delete empty directories.

Rm command

This RM command is used to delete a directory and its contents. If you just want to delete the directory (as an alternative to rmdir), please use rm -r R .. Note: Be extra careful when using this command and check your directory carefully. This will delete everything without undoing the operation.

Touch command

This touch command allows you to create a new blank file through the Linux command line. For example, enter touch/home/username/Documents/web.html to create an HTML file named Web in the documents directory.

Positioning command

You can use this command to find files, just like the search command in Windows. In addition, using the -i parameter in this command will make it case-insensitive, so you can search for a file even if you don't remember its exact name. To search for files containing two or more words, use an asterisk (*). For example, the locate -i school * note command will search for any file that contains the words "school" and "note", whether it is uppercase or lowercase.

look-up command

In a similar positioning command, you can also search files and directories by using Find. The difference is that you can use the find command to find files in a given directory. For example, the find /home/-name notes.txt command will search the home directory and its subdirectories for a file named notes.txt Other changes when using search are: To find files used in the current directory, use find. -namenotes.txt. To find the directory, please use/-type d-namenotes.txt13.grep. Another basic Linux command that is undoubtedly very helpful for daily use is grep. It enables you to search all the text in a given file. To illustrate this point, grep blue notepad.txt will search the notepad file for the word blue. The line containing the search word will be displayed completely.

Sudo command

This command is short for "super user Do" and enables you to perform tasks that require administrative or super user privileges. However, it is not recommended to use this command daily, because it is easy to make mistakes if you do it wrong.

Direction finding command

Use the df command to get a report of system disk space usage, expressed in percentage and KB. If you want to view the report in megabytes, enter df -m m m.

Du command

If you want to check how much space a file or directory occupies, the answer is the du (disk usage) command. However, the disk usage summary will show the number of disk blocks instead of the usual size format. If you want to view it in bytes, kilobytes and megabytes, add the -h parameter to the command line.

Head command

The header command is used to view the first line of any text file. By default, it displays the first ten lines, but you can change this number according to your preference. For example, if you only want to display the first five lines, type head-n5filename.ext

Tail command

The function of this command is similar to the head command, but the tail command will display the last ten lines of the text file instead of the first line. For example, tail -n file name. extension

Differential command

The diff command is the abbreviation of difference. The diff command compares the contents of two files line by line. After parsing the file, it will output mismatched lines. Programmers often use this command when they need to modify the program instead of rewriting the whole source code. The simplest form of this command is difffile1.extfile2.ext.

Tar command

The tar command is the most commonly used command to archive multiple files into a compressed package. Similar to the common Linux file format zip format, compression is optional. This command has a long list of functions, which is very complicated, such as adding new files to existing files, listing file contents, extracting contents from files and so on. See some practical examples to learn more about other features.

Chmod command

Chmod is another Linux command to change the read, write and execute permissions of files and directories. Because this command is quite complicated, you can read the complete tutorial to execute it correctly.

Chown command

In Linux, all files are owned by a specific user. This CHOWN command allows you to change or transfer the ownership of a file to a specified user name. For example, chownlinuxuser2file.ext will make linuxuer2 the owner of file.ext

Job order

The jobs command will display all current jobs and their status. A job is basically a process started by a Shell.

Kill command

If your program doesn't respond, you can use the kill command to terminate it manually. It will send a specific signal to the application running abnormally and instruct the application to terminate itself. You can always use 64 signals, but people usually only use two signals: sigterm( 15)- asking the program to stop running and give it some time to save all its progress. If no signal is specified when entering the kill command, the signal will be used. SIGKILL(9)- Forces the program to stop immediately. Unsaved progress will be lost. Besides knowing the signal, you also need to know the process identification number (PID) of the program to be killed. If you don't know the PID, just run the command ps ux. After knowing what signal to use and the PID of the program, enter the following syntax: kill [signal option] PID.

Ping command

Use the ping command to check the connection status with the server. For example, just enter ping google.com, and it will check whether you can connect to Google and measure the response time.

Wget command

The Linux command line is very useful-with the help of the wget command, you can even download files from the Internet. To do this, just type wget and enter the download link.

Uname command

UNAME command is the abbreviation of Unix name, which will print your Linux system, such as computer name, operating system, kernel and other details.

Supreme order

As a terminal equivalent to the task manager in Windows, the top command displays a list of running processes and the number of CPU used by each process. Monitoring the usage of system resources is very useful, especially if you know which process needs to be terminated because it consumes too many resources.

Historical command

When you use Linux for a while, you will soon find that you can run hundreds of commands every day. Therefore, the run history command is particularly useful if you want to view the commands you entered before.

Manual command

Confused about the function of some Linux commands? Don't worry, you can easily learn how to use them from the Linux shell by using the man command. For example, entering man tail will display the manual instruction of the tail instruction.

Echo command

This command is used to move some data to a file. For example, if you want to add the text "Hello, my name is John" to a file named name.txt, you can type Echo Hello, my name is John >; & gtname.txt

Compression and decompression commands

Use the zip command to compress the file into a zip archive, and then use the unzip command to extract the compressed file from the zip archive.

Hostname command

If you want to know the name of the host/network, just type hostname. Adding -I at the end will show the IP address of your network.

Useradd, userdel command