Developers must have a Linux command
Linux developers commonly used commands necessary to master these commands absolutely enough, based on CenterOS7.6.
System Management Services
systemctl
- Output status of each service system:
systemctl list-units --type=service
- View the running status of the service:
systemctl status firewalld
- Close Services:
systemctl stop firewalld
- Start the service:
systemctl start firewalld
- Restart the services (regardless of the current service is started or shut down):
systemctl restart firewalld
- Reload the configuration information without interrupting service:
systemctl reload firewalld
- Prohibit service boot from the start:
systemctl disable firewalld
- Set service boot from the start:
systemctl enable firewalld
Document Management
ls
Lists the current directory (/) all the files under:
ls -l /
pwd
Gets the current working directory where the absolute path
cd
Change the current working directory:
cd /usr/local
date
Display or modify the system time and date;
date '+%Y-%m-%d %H:%M:%S'
passwd
Used to set user passwords:
passwd root
its
Change the user identity (switch to superuser):
su -
clear
Clears the screen information
man
Displays help information for the specified command:
man ls
who
- Discover what the system is run level:
who -r
- Displays the current user logged on to the system:
who -buT
free
Displays the system memory status (in MB):
free -m
ps
Dynamic Display System processes running:
ps -ef
View sshd running dynamic process:
ps -ef | grep sshd
top
View real-time dynamic process, similar to Windows Task Manager
mkdir
Create a directory
more
When the paging file is too long for viewing the contents of the file 10 lines per page View boot.log file
more -c -10 /var/log/boot.log
cat
View Linux boot log file and line number indicate:
cat -Ab /var/log/boot.log
touch
Create a file text.txt:
touch text.txt
rm
- Delete Files:
rm text.txt
- Forced to delete a directory and its subdirectories:
rm -rf testdir/
cp
Test1 test2 to copy the directory to the directory
cp -r /mydata/tes1 /mydata/test2
mv
Move or overwrite the file:
mv text.txt text2.txt
Compression and decompression
takes
- The file / etc folder to the archive file etc.tar (not compressed):
tar -cvf /mydata/etc.tar /etc
- File / etc are compressed with gzip folder to the etc.tar.gz:
tar -zcvf /mydata/etc.tar.gz /etc
- With bzip2 compressed folder / etc to file /etc.tar.bz2:
tar -jcvf /mydata/etc.tar.bz2 /etc
- Page View archive content (gzip):
tar -ztvf /mydata/etc.tar.gz |more -c -10
- Unzip the file to the current directory (gzip):
tar -zxvf /mydata/etc.tar.gz
Disk and network management
df
Check disk space occupancy:
df -hT
ie
View the current file and share files in a directory folder size:
du -h --max-depth=1 ./*
ifconfig
Displays the current status of network interfaces
netstat
- View the current routing information:
netstat -rn
- View all active TCP connections:
netstat -an
- View the system start listening service:
netstat -tulnp
- View system resources in a connected state:
netstat -atunp
wget
Download the file from the network
Installation and management software
rpm
- Install the package: rpm -ivh nginx-1.12.2-2.el7.x86_64.rpm
- Fuzzy Search packages: rpm -qa | grep nginx
- Exact Match packages: rpm -qa nginx
- Query package installation path: rpm -ql nginx-1.12.2-2.el7.x86_64
- View summary information package: rpm -qi nginx-1.12.2-2.el7.x86_64
- Verify the contents of the package and installation files are consistent: rpm -V nginx-1.12.2-2.el7.x86_64
- Update Packages: rpm -Uvh nginx-1.12.2-2.el7.x86_64
- Remove a package: rpm -e nginx-1.12.2-2.el7.x86_64
yum
- Install the package: yum install nginx
- Checks can be updated package: yum check-update
- Updates the specified package: yum update nginx
- Look for package information repository: yum info nginx *
- All listed packages already installed: yum info installed
- Lists the package name: yum list nginx *
- Fuzzy Search packages: yum search nginx