Unix Common Commands Detailed Explanation

  

Chapter 1 Login

Before logging in, users must first apply for a user registration name to the system administrator. No matter which computer the user logs in to ITPNET, they will access the same. File system.

1.1 Login When the Login prompt appears on the screen, the user can enter their own user registration name and press Enter. If there is a password, the system will prompt the user to enter the password and press the Enter key. After the password is entered correctly, the user logs in successfully. At this point, some information and a command prompt will appear on the screen. Such as: Login: guest [Enter] passwd: ****** [Enter] sun% Note: User names should be entered in lowercase letters, UNIX systems are case sensitive.

1.2 Exit When the user is ready to log out of their computer account, enter logout or exit or press [Ctrl-D] under the system icon. When the Login appears on the screen, the user can safely leave the computer. For example: sun% logout [Enter] Login: 1.3 Changing the password To prevent others from using their own account, after you log in for the first time, please use the passwd command to modify the secret password that only I know. The password is usually 6 to 8 alphanumeric characters. composition. Such as: sun% passwd [Enter] Old Passwd: ****** New Passwd: ****** Retype New Passwd: ****** Note: When you log out of the system and log in again, you must use the new Password.

Chapter 2 Directory Operation Commands

2.1 Display Directory Command: pwd(print working directory) Format: pwd Function: Display the full path name of the user's current working directory. For example: % pwd

2.2 Create directory command: mkdir(make directory) Format: mkdir directory_name Function: Create a new directory For example: % mkdir directory

2.3 Change directory command: cd(change directory) Format: cd directory_name Function: Change the current working directory Note: The directory name options are: (1) Directory name, go to the subdirectory under the current directory. (2) .. means to go to the parent directory of the current directory. (3) /means to go to the root directory. (4) Go to the user's home directory when there is no option. For example: % cd directory

2.4 Delete directory Command: rmdir (remove directory) Format: rmdir directory_name Function: Delete the subdirectory name of the file that does not exist. Note: (1) When deleting a subdirectory, files or subdirectories do not exist in the directory to be deleted, otherwise they cannot be deleted. (2) If there are files or subdirectories in the deleted directory, please refer to the command rm -r directory_name. For example: % rmdir directory

Chapter 3 File Operations Commands

3.1 List File Directory Commands: ls (list) Format: ls [option] directory_name Function: List files in the specified directory Name and subdirectory name. When there is no subdirectory name, the file name and subdirectory name in the current directory are listed. Options: -a lists all files, including hidden files starting with a dot. -l lists file names in long format, including file type identifier, permissions, number of links, file name, file group name, number of bytes, date. -r lists all files in the subdirectory -g gives the identity of the user group in the long format. -t An file generation date sorting. For example: % ls -la

3.2 Display file contents Command: cat (catenae) Format: cat filename Function: Display the contents of the file. Note: When the content of the file is scrolled on the screen, press Ctrl+S to scroll the screen and press Ctrl+Q to continue. For example: % cat filename

3.3 Display file contents by screen Command: more Format: more filename Function: Press the screen to display the file content on one screen. Option: Note: There are function keys during the screen display. Space bar to continue the output of the next screen; enter the output of the next line; q key jumps out more state; /string check where the string is; a key returns to the previous screen. For example: % more filename

3.4 Page display file content Command: pg (page) Format: pg [option] filename Function: Pagination displays the contents of the specified file. When a page of a file is displayed, the last line will display the wait for the user to enter the command. The commands that can be entered have the following options. Options: h Displays the help commands available in the pg command. q Exit the pg command. [return] Displays the body of the next page. 1 Display the next line of the body [Space] Display the next page d/[Ctrl-D] Scroll the screen halfway. n Display the next file described in the pg command line. p displays the previous file described in the pg command line. % Displays the previous page of the current page of the body. /pattern Searches the specified character pattern forward in the file. ?pattern searches backward in the file for the specified character mode. Note: When the pg command is displayed to the end of the file, an end of file EOF (end of file) is displayed. For example: % pg filename

3.5 Read file Command: view Format: view filename Function: Only the contents of the file can be read. Note: This command cannot write to the original file that was read. If the original file has been modified, the modified file can be written to the new file using the command ":w newfilename". For example: % view filename

3.6 Display file header Command: head Format: head [option] filename Function: Display the header of the file Options: Default Displays the first 10 lines of the file. -i displays the beginning of the file i line. For example: % head filename 3.7 Display file tail Command: tail Format: tail [option] filename Function: Display the end of the file Options: Default Displays the last 10 lines of the file.

Copyright © Windows knowledge All Rights Reserved