Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Linux System Getting Started Tutorial: Using the Linux common commands     - Repair Raspbian Encountered a section with no Package (Linux)

- Linux dual physical network card set to a virtual NIC (Linux)

- Introduction Linux namespace (Linux)

- Ubuntu 14.04 Nvidia proprietary drivers for install two graphic cards (Linux)

- Ceph distributed storage system is installed on a CentOS 7.1 (Server)

- Linux / Windows setup is complete port range (Linux)

- VMware virtual machines to install virt-manager unable to connect to libvirt's approach (Linux)

- Android code performance optimization tips (Programming)

- Preview function to confirm the stop resource Oracle 12c new feature crsctl (Database)

- Teach you how to choose to install CentOS 6.5 installation package (Linux)

- Use libpq under Ubuntu 14.04 (Linux)

- Revised OpenJDK Java Memory Model (Programming)

- SaltStack installation and testing (Server)

- Security Features Linux and Unix operating system, programming (Linux)

- RedHat install GCC problem --- Depends (Linux)

- Linux ps command (Linux)

- Use Python automatically cleared Android Engineering excess resources (Programming)

- How to use the Linux terminal Git commands (Linux)

- Install the Solaris 10 operating system environment over the network to sparc (Linux)

- Java integrated development environment common set of operations (Linux)

  Linux System Getting Started Tutorial: Using the Linux common commands
  Add Date : 2018-11-21      

Many people may see on TV or in the movies had a similar scenario, a hacker in the face of a black screen, floating above the dense character, Bang Bang meal knock, steal information to complete the task.

Linux newborn when there is no graphical interface, all operations thanks to the completion of the command, just like on TV as a hacker, full of mysterious and obscure.

In recent years, although Linux developed very rapidly, more and more friendly and graphical interface, but the real development process, Linux command line application still plays a very important seat. You can not say that the command line, it will not Linux.

Linux provides a large number of commands, which can effectively use a lot of work done, such as disk operations, file access, directory operations, process management, file permissions settings. Linux distributions with minimal command also has more than 200 here only the most important and frequently used commands.

Use the command

Linux Format:

command [-options] [parameter1] ...


command: command name, the corresponding function English words or abbreviations of words

[-options]: Option can be used to control commands, may be omitted

parameter1 ...: arguments passed to the command, which can be zero or more of a

Example: ls -a / home

How to view the documentation:

1) - help

Linux commands are generally built with the help of information, not all commands it comes with this option.

As we want to see the usage of the command ls: ls --help

2) man (there is a problem to find a man)

man is a Linux manual provided, including most of the commands, functions, instructions for use. The manual is divided into many sections (section), you can specify different sections using man to browse different content.

man in each section have the following meanings:

1, Standard commands (standard commands)

2, System calls (system calls, such as open, write)

3, Library functions (library functions such as printf, fopen)

4, Special devices (device description file, / dev various equipment)

5, File formats (file formats, such as passwd)

6, Games and toys (games and entertainment)

7, Miscellaneous (miscellaneous, conventions and agreements, such as Linux file systems, network protocols, ASCII code; environ global variable)

8, Administrative Commands (administrative commands, such as ifconfig)

For example, we want to see ls Usage: man 1 ls (1: the number "1", it represents a section, standard commands)

In fact, we do not specify the first few chapters also used to view, such as, man ls. However, this case, if the name of the command name and function exactly the same name (eg: printf), it is both the command can also be a function of the library, if we do not specify the chapter number, man printf, only view use command does not query function usage, because man is the chapter number in the order of manual searching.

Therefore, the use of man's Manual best to specify the chapter number:


Auto completion:

In the first few letters of a command and win at the same time, press the tab key, the system will automatically help us to complete the command.

History command:

When the system execute some commands, press the arrow keys to look at the previous command, history will be executed commands listed.

Redirection (>):

The content should be displayed on the terminal is saved to the specified file.

Such as: ls> test.txt (test.txt if does not exist, it is created, exists its contents are overwritten)

Pipe (l):

When we search for files or folders containing a keyword, often you need to use the pipeline, combined with grep (search command) used together.

Pipeline we can understand the real life of the tube, the tube a plug stuff in, take out the other end, where "|" is divided into left and right ends of the left plug something, get something right.

Such as: ls | grep g, ls would have to display the contents of the screen into the left end of the pipe, and then remove these elements from the right side, in the content search there "g" keyword text.

Common Commands

File, disk management:

ls: Display directory contents

-l: List Display

-a: Display (hidden files beginning with ".") All Files

-h: with -l humane way to display the file size

clear: clear the display on the terminal can also use the keyboard shortcut: Ctrl + l ( "l" letter)

cd: Change directory

cd / mnt enter mnt (specify) directory

cd .. parent directory access

cd - can enter a directory entry

cd ~ to enter the user's home directory (~: to refer to the home directory, the home directory refers to / home in the user directory, not pure / home directory)

pwd: Display the current working directory absolute path

Note: If the path is a path starting from the root, the path in front of the need to add "/", such as "/ mnt", usually enter a directory folder, without the first "/."

mkdir: create directory

-p recursively create a folder in a specified path

cat: displays the contents of a text file

rm: Remove files or directories

-r: This parameter must be added when you delete a folder

-f: Force delete files

cp: Copying Files

-r: copies a folder

-i: When there are duplicate files, remind you whether to overwrite

-v: Display copy progress

cp vim_configure / code / -ivr vim_configure copy the folder to the code directory

mv: move files or change the file name

-v: display moving progress

mv file1 file2 file1 renamed file2mv vim_configure / code / vim_configure / moved to the code directory

which: Check the directory where the command

tar: compression and decompression command

gzip format (compressed suffix .tar.gz):

Compression Usage: tar cvzf compression bags name File 1 File 2 ...

c: create, create

v: displays the compression progress

z: Specifies the format is gzip compressed format, file.tar.gz

You can order any of these three parameters, parameters can be added in front of "-", such as: -zcf

f: behind file, document, f must be a compressed file, so when used together these four options, f must be placed at the end, such as: zxvf

Examples: tar zcvf test.tar.gz 1.c 2.c 3.c 4.c to 1.c 2.c 3.c 4.c compressed into zcvf test.tar.gz

The above operation, you could write: tar zcvf other.tar.gz * .c (. * C represent all .c)

Decompressed Usage: tar zxvf compression bag name

x: Representative decompression operation

z: Specifies extracting archive format is gzip format, file.tar.gz

Usage, and create a compressed package uses the same option order is the same.

Examples: tar zxvf new.tar.gz extract out the new.tar.gz

In fact, "z" parameter can be omitted, in which case, no matter what the format archive decompression are:

Unzip to a specified directory: -C (uppercase "C")

Examples: tar -xvf new.tar.gz -C ./test/ will new.tar.gz extract to test under the current directory

bz2 format (compressed suffix .tar.bz2):

When operating in gzip format and the same, the difference between: bz2 format parameter "j" designated

Compression Usage: tar jcvf compression bags name File 1 File 2 ...

Examples: tar jcvf bk.tar.bz2 * .c

Decompressed Usage: tar jxvf compression bag name

Examples: tar jxvf bk.tar.bz2

Unzip to a specified directory: -C

Examples: tar jxvf bk.tar.bz2 -C ./

User rights management:

chmod: change file permissions

There are two ways to use chmod format (letter method and digital method)

Letter method:

chmod u / g / o / a + / - / = rwx file

[U / g / o / a] description

u: user indicates that the owner of the file

g: group represents the owner of the file belonging to the same group (group), that is the user group

o: other that other people outside

a: all this represents all three-is

[+ - =] Instructions

+: Increases authority

-: Revoke privileges

=: Set permissions

[Rwx] Description

r: read-readable representation

w: write expressed writable

x: excute represent executable

Specific examples:

chmod o + w file to other users of the file increases file write permissions

chmod u-r file to the file minus the file owner read access

chmod g = x file settings file file with executable permissions for groups of users, while removing the read and write permissions

Digital Law:

"Rwx" These rights can also be used instead of numbers

r: read permission numerals "4"

w: Write permission, numerals "2"

x: execute or switch privilege, numerals "1"

-: Does not have any rights, numeric code "0"

Such as the implementation of: chmod u = rwx, g = rx, o = r filename

It is equivalent to: chmod u = 7, g = 5, o = 4 filename

Specific examples:

chmod 751 file

Owner of the file: read, write, execute permissions

Same group of users: read, execute permissions

Other users: execute permissions

chmod 777 file

All users have read, write, and execute permissions

Note: If you want to add the same permissions recursively all directories, you need to add the parameter "-R".

Such as: chmod 777 test -R

All files plus 777 recursive test directory.

System Management

ps: View system processes

ps -a view all processes of the current user

ps -e view the system all the processes

kill: kill the process process ID is specified, with the use ps

kill 9133 9133 for an application corresponding to the process ID

Some processes can not directly kill, this time we need to add a parameter "-9", "-9" on behalf of a forced end.

ifconfig: View or NIC configuration information

If we just knock: ifconfig, it will display all card information:

Specifies card information: ifconfig eth0 ( "0" to a number)

Set ip: sudo ifconfig eth0

sudo is to allow the system administrator to allow ordinary users to perform some or all of the root command a tool to reduce the root user login and management time and improve safety.

ping: to test network connectivity

ping not automatically stop, press "Ctrl + c" to stop

ping -c 4 "-c" representative of the number of packets sent, here 4 times

who: View information on the current system login user

The first column shows Username

The second column shows the terminal name

The third column shows the landing time


If it is a graphical interface to exit the current terminal

If you are using ssh remote login, logout account

shutdown: Shutdown

shutdown -h now shutdown immediately, which now corresponds to the time of the state 0

shutdown -h 20:25 20:25 system in today's club shutdown

shutdown -h +10 system automatically shut down after ten minutes

reboot: Restart the computer
- Recovery from MySQL master data consistency summary (Database)
- How to use secure FTP file transfer (Server)
- Ubuntu install the camera driver (Linux)
- How to convert images, audio and video formats on Ubuntu (Linux)
- CentOS7 method to upgrade the kernel to 3.18 (Linux)
- ORA-08102 errors (Database)
- Oracle 12c users create (Database)
- Linux crontab (Linux)
- Orabbix binding Python send graphical reports (Linux)
- Linux package management (Linux)
- Linux vi command list (Linux)
- Linux system crash (no such file or directory) How to rescue database (Linux)
- JavaScript notes --Objects (Programming)
- Installation Eduspec university management systems 17 Linux Mint (Server)
- MongoDB 3.0 New Features (Database)
- CentOS 6.4 installation environment to build Scrapy 0.22 (Linux)
- Use custom backup plans for Debian backupninja (Linux)
- Java reflection by calling the class method (Programming)
- Oracle 11g partition maintenance (two) - Coalescing Partitions (Database)
- The specified user to execute commands under Linux (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.