Learn common linux commands (recommended)


1、 File system management

Tips: when you enter a command, you should use the tab key to complete it

Ls view directory information (LS /)

LS – L is equivalent to LL

PWD view the current path

CD switch directory (CD /), if there is no parameter, switch to the user’s home directory~

MKDIR create folder

Rmdir delete empty folder (only empty folder can be deleted)

RM – R / A / b (delete non empty folder)

create a file

Touch a.avi to create an empty file

Edit a file with a text editor and save it

Echo “angelababy, Zhen de hen Xihuan Ni” > qingdao.txt put the output on the left into the file on the right

Delete file

RM file name (RM – R delete folder RM – RF force delete file or folder)

Move file modify file name

MV A / wenjian1.txt B / file1.txt

Copy file

cp srcFile destFile

view file contents

cat wodeqingshu.txt

More wodeqingshu.txt can be viewed in pages

Less wodeqingshu.txt can not only paginate, but also search and flip back easily

View the 10 lines at the end of the file

The log of the program is of great significance for debugging in production practice

Tail – F user.log refreshes the tail of the display file in real time

Head – 20 wodeqingshu.txt view the top 20 lines of the file

2、 Authority management


Modify permissions

CHMOD U + RWX file adds or cancels the permission of the user to which the file belongs

(U represents the user to which it belongs, O represents other users, and G represents the member users of the group to which it belongs)

Chmod 567 file can also indicate permissions by numbers

5 —> 101 —> r-x

Modify the owner of the file

chown hadoop:hadoop file Change the owner of the file to Hadoop user and the group to Hadoop group

The authority of the superior directory also restricts the operation of the file or folder at the same level

3、 User management

Add user

useradd itcast0830

Password must be set to login passwd itcast0830 normally

delete user

userdel yun12

Userdel – R itcast – delete the user’s home directory while deleting the user

Modify user properties

Usermod – L B a changes a’s login name to B

Usermod – G Hadoop itcast0830 changes the group of itcast0830 to Hadoop group

Usermod – G Hadoop, root itcast0830 add two groups of Hadoop, root to itcast0830

Usermod – D / home / itcast itcast0830 change the home directory of itcast0830 to / home / itcast
(create the itcast directory in advance and copy it into the environment variable file)

—-****—-Change the user’s password

passwd itcast0830

Add user group

roupadd beauties

Delete user group

groupdel beauties

Modify user group properties


View the current login identity


View the current group


4、 Common system management (always use root permission when it comes to modification)


Don’t use Su to switch to root easily

Ordinary users use sudo to execute root commands

For example, add Hadoop users to the sudoers file

root ALL=(ALL) ALL

hadoop ALL=(ALL) ALL

Viewing disk space information

DF – H view disk space status information

Du – sh * view the total size of all subdirectories and files in the current directory

Process information view

Free view memory usage

Top view system process information refreshed in real time

PS – EF view the process information snapshot of the current moment in the system

PS – EF | grep myshell.sh searches for information about the myshell process

Kill – 9 PID kill process (- 9 means force kill)

5、 File archiving compression (1: Packaging – archiving; 2: (compression)

1. Filing

tar -cvf testdir.tar testdir/

2. Compression

gzip testdir.tar

gzip file

bzip file

tar -czvf testdir.tar.gz testdir/

Tar – xzvf testdir.tar.gz unzip to the current directory

Tar – zxvf testdir.tar.gz – C downloads / unzip to the specified downloads directory

6、 Network management

Modify the configuration of IP address

VI / etc / sysconfig / network scripts / ifcfg-eth0 modify the configuration file to change the IP address

Or use the setup command to modify through a pseudo graphical interface with prompt

View IP address


Modify host name

VI / etc / sysconfig / network
To take effect immediately, you can execute the command hostname nidezhujiming


Host name IP address mapping of management Intranet

vi /etc/hosts yun12-01

service network restart

Service network restart under root permission
Close the firewall service iptables stop
Turn off firewall and start chkconfig iptables off automatically

Modify the default boot level of the system

vi /etc/inittab

# 0 – halt (Do NOT set initdefault to this)
# 1 – Single user mode
# 2 – Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 – Full multiuser mode
# 4 – unused
# 5 – X11
# 6 – reboot (Do NOT set initdefault to this)

Use level 3 to start the character interface in full function state

View the information of the current process connecting to the network

netstat -nltp

5、 Common tool instructions

WC statistics text information (lines, words, characters)

Date to view or modify the date and time of the system

Echo outputs the value of a string or variable

The most common text editor in VI Linux system

6、 Software installation in Linux


Unzip the installation package to your installation path

Then modify the environment variable sudo VI / etc / profile

Then source / etc / profile to take effect




The RPM package management of RedHat company is also a very common package manager

rpm -qa | grep mysql
sudo rpm -e mysql-libs-5.1.66-2.el6_3.i686 –nodeps
sudo rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm

The above is Xiaobian to introduce you to learn Linux common command (recommended), hope to help you, if you have any questions please leave me a message, Xiaobian will reply you in time. Thank you very much for your support to developer!