In this article, we will introduce some of the basic commands used in the Linux shell.
View and jump commands
(1) pwd
When you open the terminal, if you need which directory you are currently in, you can use pwd command, which returns an absolute path (the path starting from the root "/").
(2) ls
Use the "ls" command to know what files and folders are in the directory you are in. You can use the command "ls -a" to view all hidden files.
(3)cd
Use the "cd" command to jump to the corresponding directory. When using it, make sure that the following target directory exists.
Free video tutorial recommendation: Linux video tutorial
File and folder commands
(1)mkdir and rmdir
mkdir is used to create directories, and rmdir is used to delete directories. Note that rmdir can only be used to delete an empty directory. To delete a directory containing files, use rm.
(2)rm
Use the RM command to delete files and directories. But RM cannot simply delete the directory. Use "rm -r" to delete a directory (followed by an argument r). At this time, the folder and the files in the folder will be deleted.
(3) touch
The touch command is used to create files. It can generate any file, it can be an empty txt file or an empty zip file.
For example:
##copy and move file
(1) cp use The cp command copies files. It requires two parameters: the first is: where to copy the file from, and the second parameter is where to copy the file to? (2)mvUse the mv command to move the file. We can also use the mv command to rename files. The usage is similar to cp. For example:The above is the detailed content of How to use shell commands in linux. For more information, please follow other related articles on the PHP Chinese website!