Here we introduce the common Basic command one, log off shutdown restart logoff system logout Command 1Logout logoff is the relative operation of the landing system to leave the system users as long as the direct release of the logout command: [[email protected] root]# Logout Red Hat linuxrelease 9 (shike) Kernel 2.4.20.8 on an i686 login:← back to landing screen 2 shutdown or restart shutdown Command shutdown command can be To turn off all programs to restart or shut down according to the user's needs. The parameters are described as follows: Shut down immediately: the-H parameter shuts down the system immediately. The example is as follows: [[[email protected] root] #shutdown –h now← requires the system to be shut down immediately specify shutdown time: The time parameter can specify when to shut down, or the example of how long to run the shutdown command is as follows: [[EM Ail protected] Root] #shutdown now← shut down immediately [[email protected] root] #shutdown +5←5 minutes after shutdown [email protecte D] Root] #shutdown 10:30← automatically restarts after shutting down the machine at 10:30:-r parameter is set to restart after shutdown. The example is as follows: [[[email protected] root] #shutdown-R now← immediately shuts down the system and restarts [[email protected] root] #shutdown-R 23:59← specified in 2 3:59 Restart 3 The reboot command that restarts the computer as the name implies reboot command is used to reboot the system. The commonly used parameters are as follows:-F parameter: Shut down the system directly and restart the computer if the program is not in normal operation. -I parameter: Close all network interfaces before restarting. Although the reboot command has a parameter you can use but generally only need to run the reboot command alone. The LS command 1ls (list) command, which lists files and directories, is a useful command to display a list of files and subdirectories in the current directory. The use of mate parameters can display directory content in different ways. Examples are as follows:? Displays the current directory'sContent: [[email protected] tony]$ ls Desktop mail myinstall.log test.txt← has two directories and two folders? Files with the name beginning with ―.‖ are not displayed when the LS command is run. Therefore, you can add the ―-a‖ parameter to specify that you want to list these files. Examples are: [[email protected] tony]$ ls–a? Displays all of the space for each file in the ―-s‖ parameter and specifies the size of all occupied space as the ―-s‖ parameter. Examples are: [[email protected] tony]$ ls–s–s Total 4 Desktop 4 mail myinstall.log 4 test.txt? The contents of the directory are listed directly after the LS command by adding the directory path to be displayed. Examples are as follows: [[email protected] tony]$ ls–l/usr/games 2 Switch Directory CD command CD (change directory) command allows users to cut the current directory. Here's an example: [[[Email protected] home]$ CD tony← switch to Tony subdirectory under current directory [[email protected] tony]$ CD. ← Switch to the previous level directory [[[email protected] home]$ CD/← switch to system root [[email protected]/]$ cd← switch to user home directory [[Email pro Tected] tony]$ cd/usr/bin← switch to/usr/bin directory 3 create directory Mkdir commands Mkdir (make directory) commands can be used to create subdirectories. The following example creates a tool subdirectory in the same directory. [[email protected] tony]$ mkdir tool 4 Delete directory rmdir command rmdir (remove directory) command can be used to delete-empty ‖ subdirectory. Examples are as follows: [[email protected] tony]$ rmdir tool← Delete tool directory 5 CP command for copying files cp (copy) lifeEnables you to copy files from one place to another. It is generally necessary to specify the original file name and destination file name or directory when using the CP command to copy a file to another file or to a directory. Examples are as follows: [[email protected] tony]$ cp data1.txt data2.txt← copy Data1.txt to Data2.txt [[email protected] tony]$ CP data3.txt/tmp/data← Copy the data3 to the/tmp/data directory? Show replication process: Join the-v parameter to display the command execution process. Examples are: [[email protected] tony]$ CP zip.txt zip2.txt← General status does not show the copy process [[email protected] tony]$ cp–v zip.txt zip3.txt← Displays the copy process Zip.txt->zip3.txt with-V? Recursive system: Add the ―-r‖ parameter to copy all the files and subdirectories in the directory at the same time. Examples are: [[[email protected] tony]$ cp–v–r * backup← copy all files (including subdirectory files) to the backup directory 6 RM command RM (remove) command to delete files or directories Recorded. Example: [[[email protected] tony]$ RM myfile← Delete the specified file [[email protected] tony]$ rm *← Delete all files in the current directory the common parameters of the RM command The numbers are as follows:? Forced Delete: When using the-f parameter, the RM command will delete the file directly and no longer ask. Examples are: [[email protected] tony]$ rm–f *.txt← forcing files to be deleted? Recursive Delete:-R is also a fairly common parameter use this parameter to delete all files and subdirectories in the specified directory at the same time. Example: [[[email protected] tony]$ rm–r data← Delete the data directory (with all files and subdirectories in the data directory) [[email protected] tony]$ rm–r *← Delete all files (including all subdirectories and subdirectories of all files in the current directory)files)? Force deletion of the specified directory: When you delete a directory with the-r parameter, if there are many subdirectories and files in that directory, the system will continuously ask to confirm that you really want to delete the directory or file. If you have determined that you want to delete the stored directory and file, you can use the-RF parameter so that all files and subdirectories in that directory will be deleted directly from the system and no longer asked. Example: [[[email protected] tony]$ rm–rf tmp forcibly delete the TMP directory and all files and subdirectories in that directory? Show Delete procedure: Use the-v parameter. The example is as follows: [[[email protected] tony]$ rm–v 7 Let the display pause the more command In order to avoid a flash of the screen display the user can use the more command to let the screen display full page Pause at this time can press the SPACEBAR to continue to display the next screen or press the Q key to stop the display. When you use the LS command to view a list of files, you can use the more command if there are too many files. Examples are: [[email protected] bin]$ ls–al more? You can use the more command alone to display the contents of a text file. Examples are as follows: [[[email protected] tony]$ more Data.txt 8, the Cat Command Cat (CONCATENATE) command that connects files can display the contents of a file (often with the more command) or to combine several files and into a file. Examples are as follows:? Page Preface.txt: [[email protected] tony]$ cat preface.txt more? After attaching the preface.txt to the Outline.txt file: [[email protected] tony]$ cat preface.txt >> outline.txt? Merge New.txt and info.txt into readme.txt files: [[email protected] tony]$ cat new.txt info.txt >readme.txt 9, move or replace MV of file directory name The command MV (move) command allows you to move files and directories under another directory or replace the names of files and directories. Examples are as follows: [[email protected] backup]$ mv A.Txt.. ← Move the A.txt file to the upper directory [[email protected] backup]$ mv z1.txt z3.txt← rename z1.txt to Z3.txt [[email protected] backup] $ CD. ← Switch to the previous level directory [[email protected] tony]$ MV Backup. ←backup directory up one level 10 the PWD command pwd (print working directory) command that displays the current directory displays the directory where the user is currently located. The example is as follows: [[email protected] tony]$ pwd/home/tony← current directory is ―/home/tony‖11, find file Locate command Locate command can be used to search for containing the specified condition string The file or directory. Here's an example: [[email protected] tony]$ Locate ZH_CN lists all files and directories that contain ―zh_cn‖ strings. Because the locate command searches the database for files and directory names from the system, although the system updates the database periodically but for newly added or deleted files, The directory may still not be able to be traced because the database has not been updated to run the UpdateDB command at this time to update the database with the correct content. 12 Search string The grep command grep command can search for a specific string and display it in general to filter out previous results to avoid displaying too much unnecessary information. Here's an example: [[email protected] etc]$ grep text *.conf← searches the current directory for files with a. conf extension and a ―text‖ string. Grep:amd.conf:← refused to do not comply with the permission of the Operation Grep:diskcheck.conf:← refused to comply with the operation Grep:grub.conf← denied permission to operate? If you are running a user with general privileges, the output from the example above will contain many error messages such as-------------------- [[email protected] etc]$ grep–s text *.conf 13 re-conduction and pipeline re-conduction (redirect) The result of a command can be output in a guide file it has two commands:->‖ and ―>>‖. ―>‖ can output the result to a file where the original contents of the file are deleted: ―>>‖ appends the result to the file, the contents of the file will not be erased. The example is as follows: [[email protected] tony]$ ls–a>dir.txt← outputs the ls–a command execution results to the Dir.txt file. [[email protected] tony]$ cat data1.txt >> data2.txt← append data1.txt content to the Data2.txt file. The symbol for the channel (pipe) command is ―‖ to output the results of a command to another command. The example passes the output of the LS command to the grep command filter: [[email protected] etc]$ ls gerp conf← search for and display the LS command run results package An example of a delete file or directory containing a ―conf‖ string can be passed to the RM command using the Yes command to repeat the output of the ―y‖ character so you can avoid repeated input ―y‖: [[email protected] tony]$ Yes rm–r Mydi R third, using CD-ROM and floppy disk in the Linux text mode to use the disc or floppy disk is not only put the CD or floppy disk can be run by the user needs to load the command to read and write data. Loading is the designation of storage media (such as discs and floppy disks) as a directory in the system (such as/mnt/cdrom or mnt/floppy). Data from the storage media can be read and written by direct access to this loading directory. Here's a look at the loading and unloading commands in text mode. 1 Load the mount command to use the disc, first put the CD into the CD-ROM drive and then execute the loaded mount command to load the CD into the system: [[[email protected] tony]# mount/dev/cdrom/mut/cdrom← loading disc Similarly, a floppy disk must be loaded before it can be used before using it: [[email protected] tony]# mount/dev/fd0/mut/floppy← loading floppy disk 2 Uninstall Umount command If you do not need to use a disc or floppy disk You must execute the uninstall command before you can exit the disc or floppy disk. Examples are as follows: [[email protected] tony]# Umount/mnt/cdrom← CD Unmount When you do not use a floppy disk when you execute the umount command to unmount the floppy disk and then remove the floppy disk [[email protected] tony]# umount/mnt/← floppy disk unloading four, running programs in the background sometimes the program may take a lot of time as The best way to run it in the foreground will cause you to not be able to continue doing something else is to run it in the background and you might even want the program to continue running after the user logs off the system. Let's see how that can be achieved. 1 The easiest way to run a program in the background with the &, BG command to put the program in the background is to add ―&‖ to the command at the end, as shown in the following example: [[email protected] root]# updatedb &← performing locate in the background Database Update command [[email protected] root]# bg← to put the update operation in the background run the 2 foreground program FG Command if the user currently has a program running in the background you can enter the FG command to move it from the background to the foreground to run: [[email protected] root]# fg← the command executed at the foreground will show 3 the nohup command to keep the program running after exiting this command allows the program to continue running after the user exits the system. The example is as follows: [[email protected] rony]$ nohup myserver & then the user can exit and when you log in again, you can see that the program is still running in the background with the Ps–aux command. Five, task scheduling commands the computer has many programs that need to be used periodically, such as cleaning up disk scratch disks, backing up system data, checking messages from remote servers, and so on. For these repetitive tasks, it is not necessary to run these programs every time. You can use task scheduling commands to specify that the system periodically runs these programs at a certain time to easily complete the work you want to do. The Crond resident command for task scheduling Crond is a command that Linux uses to execute programs on a regular basis. This task Transfer command is started by default when the operating system is installed. The Crond command periodically checks to see if there is work to be done and that work is performed automatically if there is work to be done. Because the operation process in the middle of task scheduling is very complicated. We only introduce the task scheduling file to everyone for your reference: Minute Hour Day Month DayOfWeek Command in this text except ―command‖ is the field that must be specified each time other than automatically CanDecide whether or not to specify as required. Six, task scheduling system work/ect/crontab/file is the Linux system Engineering task scheduling settings file its default content is as follows: shell=/bin/bash← Specifies the SHELL that is used to perform task scheduling work PATH=/SHIN:/BIN:/USR /sbin:/usr/bin← specifies the path of the command search mailto=root← specifies that the output will be given to the root user home=/← specified with directory VII, task scheduling of the individual work in addition to the above task scheduling system work, the general user can use the Crintab command from Line sets the work to be performed on a regular basis. Each user can execute the crontab–e command to edit his or her task scheduling settings file and join the work to be performed on a regular basis in this file. The following example sets the task schedule file for the tony user to edit: [[email protected] rony]$ crontab–e executes the above command and then goes to the vi text editor to edit the task schedule itself. Viii. Delete a scheduled job task if you do not want to perform the work in a task transfer on a regular basis, you can execute the crontab–r command to remove all task scheduling. Examples are: [[[email protected] rony]$ crontab–r← Delete Work in Task Scheduler [[email protected] rony]$ crontab-1← View work in Task Scheduler again No crontab for tony← no task scheduling work nine, packaging, compression and decompression because this is the basic functionality that every Linux user will often use, we will introduce the most common packaging, compression, and decompression programs. 1 tar command for packaged files tar command in the/bin directory it can package a user-specified file or directory into a file, but it does not compress. Generally, the common Unix compression method is to first use the TAR command to package many files into a file and then compress the file with the compression command such as gzip. The parameters of the tar command are described in a variety of examples:? -C: Create a new tar file; ? -V: Displays the operation process information; ? -F: In: Specify the file name; ? -Z: Call the gzip compression command to perform the compression; ? -j: Call the BZIP2 compression command to perform the compression; ? -T: See the contents of the compressed file; ? -X: Unpack the tar file. In this case a common example: [[Email protEcted] data]# tar cvf data.tar *← package All files in the directory into Data.tar [[email protected] data]# tar cvf data.tar.gz *← Package All files of the directory into Data.tar use the gzip command to compress [[email protected] data]# tar TVF data.tar *← see which files are included in the Data.tar file [[email protected] Da ta]# tar xvf data.tar *← Data.tar 2 compression and decompression the TAR command itself does not have the ability to compress but can use other compression commands immediately after the resulting tar file to compress the provinces need to enter two orders of trouble. Use the-Z parameter to unlock the most common. tar.gz file: [[email protected] data]# tar–zxvf foo.tar.gz← Unpack the file into the current directory? Use the-j parameter to unpack the tar.bz2 compressed file: [[[email protected] data]# tar–jxvf linux-2.4.20tar.bz2← Unpack the file into the current directory? Use the-z parameter to specify that the Compress command compresses [[email protected] data]# TAR–CZVF prcture.tar.z*.tif all the. tif packages and commands in that directory are compressed into. tar.z File X. Other commonly used commands for Linux are quite a few of the commands available in this chapter we only cite a few common commands to illustrate the many other commands that will be exposed in later chapters. 1 The passwd command passwd (password) command to change the password allows the user to change the password. Examples are: [[email protected] tony]$ passwd changing password for user Tony changing password for Tony (current) U NIX password:← Enter the original password new password:← Enter the password retype the new password← here Enter the password Passwd:all authentication tOkens updated successfully← Password modification successful 2 creating a boot Disk mkbootdisk command if the system is installed without a boot disk or the boot disk is compromised you can create a new boot disk after installing the system with the Mkbootdisk command: [[ Email protected] root]# mkbootdisk? uname-r ' Execute the instructions above to successfully create a boot disk. Please save the shavings for urgent use. 3 Displays the date, clock, and Ntpdate command with the Set time Date command to display the current date time. Examples are as follows: [[email protected] rony]$ date-9 month 8 10:00:00 CST 2006 CST is the Central Standard Time Clock command can also display the current date and time of the system but the clock command does not allow the default General user Execution Please use the root account: [[[email protected] root]# clock CE September 8, 2006 (Friday) 10:00 00 seconds 0.112604 seconds If the system time is incorrect to change you can use the DA Te command to set the time. Use the root account as follows: [[[email protected] root]# date 09091200← set the time to September 9 12:00 The user may sometimes suffer from a lack of knowledge of standard time. It doesn't matter. There is also standard time provided by the server on the current network for proofreading. Therefore, the executable ntpdate command sets the system time to coincide with the school time server: [[email protected] root]# ntpdate stdtime.microsoft.com← and Microsoft School. Then execute the date command again to find that the system time has changed. But it's not over yet. It is also necessary to execute the clock–w command to write the changed time to the computer's CMOS so that the changed time is not used at the next boot. The example is as follows: [[email protected] root]# clock–w Common basic commands we'll start with the introduction here, and now we're going to talk about some new ways to solve some of the problems encountered in the process of use and some of the techniques used during the operation. First, how to enter the text mode when installing Linux, you can choose to enter the text mode or when the graphics mode. If you select the text mode, you canIf you enter the graphics mode directly into X window, you can still enter text mode in the following ways: 1 Open Text Mode window in X window in the Default GNOME window environment for example, the simplest way to enter text mode under X Windows is to click the right mouse button in the blank space of the desktop. -Added terminal command ‖ Open Text Mode window. In the text mode window, you can use the Shift+page up and shift+page dwon keys to scroll through the contents of the window. 2 Switching the virtual main console into text mode the Linux host provides 7 virtual consoles under the main console (console) to run their own programs in each Virtual Console. You can switch to the other virtual consoles by pressing the CTRL+ALT+FN key at any time after landing the X Window System. The FN is the function key of F1F7. 3 launch direct into text mode to set the start-up directly into text mode you can use any text editor to open the/etc/inittab file to find ―id:5:initdefault:‖ in the file and change it to ―id:3:initdefault:‖. Second, Etc/inittab Setup error causes Unable to start if you modify the/etc/inittab, you can enter the system to re-modify the Inittab settings file to resolve the problem by using single-player mode at startup. If you use grub as the boot loader, simply press the a key when starting the display menu and enter the parameters at the command line to enter single-player mode: Grub append > Ro root=label=/s← as long as the command line after the original statement ―s‖ can use Lilo as the boot loader program When you start to display the Lilo menu screen, press ctrl+x to switch to the Lilo login screen in text mode and enter the following parameters: Boot:linux s← indicates that the system is directly speaking into single-player mode three, how to query the use of commands in a Linux system if the user command function is not clear You can use the man command to query for help: [[email protected] root]# man shutdown← uses the man command to query the use of SHUTDOWN commands to be introduced later. The syntax for most commands can also be queried by the-H or-help parameters. For example the syntax of the shutdown command can be run Shutdown–h or the above man shutdown command is checked. Iv. Avoid pressing Ctrl+alt+del Restart the system in Linux directly press Ctrl+alt+del threeThe key will restart if you do not want anyone to use this set of keys to restart the computer at will. Please modify the/etc/inittab file with a text editor: #ca:: Ctrlaltdel:/sbin/shut down–t3–r now← Add ―#‖ before this. After you save and restart the calculation, you cannot restart with the Ctrl+alt+del key. Five, text mode of Chinese information garbled how to do in this version of Red Hat Linux if the X window opens the Text mode window in text mode operation, all Chinese filenames, months and even some of the information can be normal in Chinese display. However, in the text mode of the Virtual Console, these Chinese information will become garbled at this point, please do the following to change this information to the English display: [[email protected] root]$ lang=c [[email protected] root]# ls –l run lang=c command after the original in Chinese display (garbled) of the part into English if you want to change back to the original settings, as long as the LANG=ZH_CN command can be executed: [[email protected] root]$ lang=zh_cn VI, see Chinese text Name if the loaded storage media contains Chinese file names, you need to run the Mount command plus the ―-o iocharset=cp950‖ parameter to see the Chinese file name in this save media. For example, loading a disc allows you to execute the following command: [[[email protected] root]# Mount–o iochatset=cp950/dev/cdrom/mnt/cdrom Seven, how to swap discs when the disc has been loaded into a directory Pressing the exit button on the optical drive will not eject the disc you must first unmount the disc before exiting the disc. If the current location is the CD-ROM loading directory (such as/mnt/cdrom), or there are other users in this directory will not be able to successfully uninstall it, of course, can not exit the disc: [[email protected] root]# Umount/mnt/cdrom Umount:/mnt/cdrom:device is busy← This disc is being used to switch the working directory elsewhere or require other users to leave the directory before uninstalling the directory and exiting the disc. After changing the shutdown, remember to load the disc again before you can use it. Viii. allow normal users to load discs or floppy disks the Linux operating system only allows the root user to run the Mount command by default if the generalWhen the user executes the above command, the following error message appears: [[email protected] root]# mount/dev/cdrom/mut/cdrom mount:only root can do that← only the root user can Execute this command so to allow normal users to load discs or floppy disks, modify the/ect/fstab/settings file:/dev/cdrom/mut/cdrom udf,iso9660 noauto,owner,kudzu,ro,user← To let the average user also load the disc, add the ―user‖ project here. There are a lot of other application instructions for Linux that we will follow in future learning and application.
Linux basic commands