Getting Started with Linux Basic Instructions (1)

This article introduces some common basic instructions in Linux for your study and reference. 

Table of contents

ls command

pwd command

cd command

.and..

touch command and mkdir command

rm command

man command


 

ls command

Syntax : ls [ options ] [ directory or file ]
Function : For a directory, this command lists all subdirectories and files under the directory. For files, the filename is listed along with other information.
Common usage:
ls -l: list the detailed information of the file
ls -a: s lists all files in the directory, including hidden files beginning with .

pwd command

Function : Display the current directory of the user.

cd command

Syntax : cd directory name.
Function : Change the working directory. Change the current working directory to the specified directory.

Common usage:

cd ~ : enter the user's home directory.
cd - : Returns the most recently accessed directory.
cd root/cx/a.txt : Absolute path access.

.and..

In the Linux command, . represents the current directory .. represents the parent directory

Common usage:

cd ..  Return to the parent directory

cd ../day02/ : relative path access
./test.out : Execute the executable program

touch command and mkdir command

Syntax : touch [ option ] [ file]
Function : The touch command parameter can change the date and time of the document or directory, including access time and change time, or create a file that does not exist.
Common usage:
touch test.txt : Create a document in the current directory
Syntax : mkdir [ options ] name
Function : Create a directory named name under the current directory .
Common usage:
mkdir newname : Create a new directory under the current directory.
mkdir -p test/test1/test2/test3 : Create multiple directories recursively.

 Note: Documents and directories are different. In a directory tree, documents or empty directories must be the leaf nodes of the tree, while non-empty directories are the branch nodes of the tree.

rm command

The above touch and mkdir commands are the creation of files and directories, followed by the deletion of files and directories.

Syntax : rm [-firv][dirName/dir
Function : delete a file or directory.
Common usage:
rm file name : delete file (leaf node)
rm -f filename : force delete file (do not ask)
rm -r directory name : recursively delete the directory and all files under it.
rm -f -r directory name : recursively delete the directory and all files under it (do not ask)

man command

Function : Linux commands have many parameters, we cannot remember all of them, we can get help by checking the online manual. The command to access the Linux man pages is:
Syntax : man [ options ] command
-k Search manpage by keyword
num is only found in chapter num
-a will display all the chapters, such as man printf , it will start searching from the first chapter by default, stop when you know it, use the a option, when you press q to exit, it will continue to search until all chapters are searched
Common usage:
man [command] : Enter the manual, press 'q' to exit, and use the up and down keys on the keyboard to view the document.

The next article introduces file viewing, modification, etc. to file content instructions. 

Guess you like

Origin blog.csdn.net/2301_76144863/article/details/131903355