Basic Shell commands in Linux

Working on the Linux operating system you cannot not know the basic shell commands. For ease of operation on Linux, TipsMake.com has compiled some basic Linux shell commands, please consult.

Working on the Linux operating system you cannot not know the basic shell commands. For ease of operation on Linux, TipsMake.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 "(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 the operating system. understand is different from ' a '.

To access the file system , use:

  1. pwd : take out the active directory screen (eg / etc / ssh).
  2. cd : change the directory (eg cd . - issue an existing directory level; cd vidu - into the directory / vidu).
  3. ls : give list of directory contents.
  4. mkdir : create a new directory ( mkdir name_thumuc ).
  5. touch : create new file ( touch ten_file ).
  6. rmdir : remove a directory ( rmdir ten_thumuc ).
  7. cp : copy file or directory ( cp file_domain file_directory ).
  8. mv : move files or folders; It is also used to rename files or folders (new location_access location or new name_v_name ).
  9. rm : remove file ( rm name_file ).

To search for files , you can use:

  1. tìm : used for file names.
  2. grep : to find content in the file.

To view a file , you can use:

  1. more : display file by page.
  2. cat : display all files.
  3. head : display the first line.
  4. tail : displays the last line (which can 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 .

To extract an archive (usually with tar.gz extension), you must use the tar command with tar -xvf syntax .

To print a file , use the lpr command . 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 lpq command), using the lprm statement .

To install or remove devices (add to the file system as a means of use), use:

  1. mount / mnt / floppy : install a floppy drive.
  2. umount / mnt / floppy : remove the floppy drive.
  3. mount / mnt / cdrom : install the CD-ROM drive.
  4. 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 the mount command ( mount / dev / source / mnt / new drive_disk ), in which / dev / sour ce is the device (ie the 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 .

System management :

  1. 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 command.

 

  1. top : works quite like Task Manager in Windows. It gives information about all system resources, running processes, average load speed . The top -d command sets the interval to refresh the system. You can set any value, from .1 (ie 10 milliseconds) to 100 (ie 100 seconds) or even larger.
  2. 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, hard disk I / O, network load speed) used at a time. If the rate is calculated at 0.37, 37% of the resources are used. Larger values ​​like 2.35 mean that the system has to wait for some data, then it will calculate 235% faster without any problems. But between distributions may vary slightly.

 

  1. free : display information on the system memory.
  2. ifconfig : 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 ifconfig command. up / down .
  3. passwd : allows you to change the password ( passwd user_community_key or other user name if you log in to the system as root).
  4. useradd : allows you to add new users (see man useradd ).
  5. 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 the 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 could be: mkdir mail_delete_1;mkdir directory_2;mkdir directory_3 .
  6. 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.
  7. If at any time you are required to log in with the root account ("super" admin of the system), you can log in temporarily 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.

To exit or close the shell , type exit or logout .

Update 26 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile