Working on a Linux operating system you cannot not know the basic shell commands. For ease of operation on Linux, Quantrimang.com has compiled some basic Linux shell commands, please consult.
When you open a shell, you need to go to the activation account in the home directory (usually in / home / usernames).
Notice that each command has its own options. To see options for a specific command, simply type ” man <command> ” (where: man is the keyword; command is the command name). An important point to note is that in Linux operating systems, the command is case sensitive. ” A ” will be understood by the operating system to be different from ” a “.
To access the file system , use:
- pwd : take out the active directory screen (eg / etc / ssh).
- cd : change directory (eg cd .. – issue an existing directory level; cd vidu – go to directory / vidu).
- ls : give list of directory contents.
- mkdir : create a new directory ( mkdir name_thumuc ).
- touch : create new file ( touch ten_file ).
- rmdir : remove a directory ( rmdir ten_thumuc ).
- cp : copy file or directory ( cp file_domain file_directory ).
- mv : move files or folders; It is also used to rename files or folders (new location_access location or new name_vs_name ).
- rm : remove file ( rm name_file ).
To search for files , you can use:
- find <search criteria> : for file names.
- grep <search criteria> : to find content in the file.
To view a file , you can use:
- more <file name> : display file by page.
- cat <file name> : display all files.
- head <file name> : display the first line.
- tail <file name> : displays the last line (which may be useful in situations like when you want to see the final information of a file system).
To edit the file , you must use the built-in editor on the command line. Usually, this is vi and is used with the syntax: vi <file name> .
To extract an archive (usually with tar.gz extension), you must use the tar command withtar -xvf <file> .
To print a file , use the lpr command <name_file> . Note that you must have some daemons running to manage the printer. Usually these are cups (mainly UNIX Printing System) that can be used for all major distributions.
To remove the file from the queue at the printer (you can list the queue with the lpqcommand), use the lprm command <filename> .
To install or remove the device (add to the file system as a means of use), use:
- mount / mnt / floppy : install a floppy drive.
- umount / mnt / floppy : remove the floppy drive.
- mount / mnt / cdrom : install the CD-ROM drive.
- mount / mnt / cdrom : remove the DC-ROM drive.
These devices are usually installed and allowed to be used automatically. But maybe one beautiful day you have to do this work yourself when an error occurs. Do not worry!
To create a partition
First, create a directory in / mnt ( mkdir / mnt / new disk_disk ). Then use mountcommand ( mount / dev / source / mnt / new drive_disk ), in which / dev / sour ce is the device (ie partition) you want to add to the file system.
If you want to connect to a remote host , use the ssh command. The syntax is ssh <name_host> .
System management :
- ps : shows the currently running programs (very useful: ps is a full view of all programs). In the list given when executing the ps command, you will see a PID number (Process identification). This number will be asked when you want to stop a service or application, use the kill <PID> command .
- top : works quite like Task Manager in Windows. It gives information about all system resources, running processes, average load speed … The top -d <delay> command sets the time to refresh the system. You can set any value, from .1 (ie 10 milliseconds) to 100 (ie 100 seconds) or even larger.
- uptime : represents the system time and average load speed during that period, previously 5 minutes and 15 minutes. Usually the average load speed is calculated by the percentage of system resources (processor, RAM, input / output hard drive, network load speed) used at a time. If the rate is calculated at 0.37, 37% of the resources are used. Larger values such as 2.35 mean that the system must wait for some data, then it will calculate 235% faster without any problems. But between distributions may vary slightly.
- free : display information on the system memory.
- ifconfig <interface_name> : to view detailed information about network interfaces; Usually the ethernet network interface is named eth () . You can install network settings such as IP addresses or by using this command (see man ifconfig). If something is not correct, you can stop or start the interface by using the ifconfigcommand <username_settings> up / down .
- passwd : allows you to change the password ( passwd user_community_key or other user name if you login to the system as root).
- useradd : allows you to add new users (see man useradd ).
- Whatever distribution you have, you can use the TAB key to automatically complete a command or file name. This is useful when you are familiar with commands. You can also use the up and down keys to scroll through the entered commands. You can use multi-line commands on one line. For example, if you want to create three directories on a single line, the syntax can be: mkdir mail_delete_1; mkdir directory_2; mkdir directory_3 .
- Another interesting thing is the pipe commands. You can export a command via another command. For example: man mkdir | tail will show the final line information in the “manual” view page of the mkdir command .
- If at any time you are required to login with the root account (“super” admin of the system), you can log in temporarily by using the su command . The parameter -1 ( su-1 ) is used to change the home directory and for commands already in use. Note that you will also be prompted for a password
- exit or close the shell, type exit or logout.