Linux daily use command Daquan
Java code
Www.ahlinux.com
001, daily maintenance of common query commands
#top Show System processes
#clear Cleaning up screen information
#cat/etc/redhat-release View System version information
#cat/proc/version to view information such as the system kernel version
#uname-A To view information such as the system core
#cat/proc/cpuinfo View CPU Information
#cat/proc/meminfo View memory information
#cat/proc/swaps View Swap space information
#getconf Long_bit to see if the CPU is 32-bit or 64-bit
#dmidecode |more How to view BIOS information, and so on.
#grep memtotal/proc/meminfo View Physical Memory information
#grep Swaptotal/proc/meminfo to see the size of the swap space
#cat/etc/passwd View account information
#cat/etc/shadow View password information
#cat/etc/group See which groups are in each group, which users are included, or #vigr
#groups username to see which group a user belongs to
#ps-aux shows all processes on the terminal, including the processes of other users.
#ps-X shows no process to control the terminal.
#ps-e Displays all processes.
#ps-R Displays only the processes that are running.
The free command can view memory utilization
CPU usage information in the TOP-N1 command
002. Modify the start-up interface to text mode (Command mode)
3 is Text mode and 5 is graphic mode.
#vi/etc/inittab
Modify Id:5:initdefault: For Id:3:initdefault:
003, modify the Remote management command line under the Chinese garbled problem
The default language encoding for Red Hat Enterprise Linux is "ZH_CN." UTF-8 ", in the X-window desktop environment can display Chinese characters normally, but if through SSH or telnet, such as remote management, you will find all the characters have become garbled.
#vi/etc/sysconfig/i18n
Will lang= "ZH_CN. UTF-8 "changed to Lang=" ZH_CN. GB18030 ", the Chinese characters will be displayed normally after re-login.
System default English language:
Edit/etc/sysconfig/i18n
Lang= "en_US. UTF-8 "
Supported= "en_US. Utf-8:en_us:en "
Sysfont= "Latarcyrheb-sun16"
System default Chinese language:
Lang= "ZH_CN. UTF-8 "
Supported= "ZH_CN. Utf-8:zh_cn:zh "
Sysfont= "Latarcyrheb-sun16"
The system default English language, while supporting the Chinese language:
Lang= "en_US"
Language= "en_US"
Supported= "ZH_CN. GB18030:zh_CN:zh:en_US. Utf-8:en_us:en "
Sysfont= "Lat0-sun16"
Sysfontacm= "8859-15"
004, configure the network card related information
#cd/etc/sysconfig/network-scripts
#ls
#vi Ifcfg-eth0
Device=eth0
Bootproto=static
broadcast=192.168.0.255
Hwaddr=00:17:31:7f:6b:a7
ipaddr=192.168.0.68
netmask=255.255.255.0
network=192.168.0.0
Onboot=yes
Type=ethernet
: Wq exit.
#service Network restart to restart networking
005. Change host Name
#vi/etc/sysconfig/network
Rename the hostname and restart.
006, consider the security issue, only allow the normal account directly telnet, do not allow root direct login
Configure sshd
Start sshd service:/etc/init.d/sshd start
Edit the/etc/ssh/sshd_config file, locate the statement Permitrootlogin Yes, and modify Yes to No.
Restart the SSHD service:/etc/init.d/sshd restart
007. Turn off unwanted system services
To install a system that performs better, it is recommended to close some unnecessary system services such as cups, SendMail, ISDN, SMARTD, Iptables, PCMCIA ... such as
#chkconfig cups off
#chkconfig SendMail off
#chkconfig ISDN Off
#chkconfig SMARTD off
#chkconfig iptables off
#chkconfig PCMCIA Off
008. Modify DNS
Standard format: NameServer DNS Address
#vi/etc/resolv.conf
NameServer 192.168.0.36
NameServer 202.106.0.20
: Wq #保存退出.
#service Network Restart #重新启动网络
009. Check the partition of the system disk and the location where the file system is mounted
#df –h
Filesystem Size used Avail use% mounted on
/dev/hda3 36G 4.1G 30G 12%/
/DEV/HDA1 190M 8.4M 172M 5%/boot
None 248M 0 248M 0%/dev/shm
#df-H/Home View disk usage for the partition on which you reside
010. View the size of the directory and the files in the directory, or view the size of individual files
#du-H directory or file
[Email protected]/]# DU-H/tmp
12k/tmp/.font-unix
8.0k/tmp/. Ice-unix
12k/tmp/ssh-wdiorjg370
36k/tmp/test
164k/tmp
[Email protected] tmp]# du-h 1.txt
8.0K 1.txt
Du-sh directory or File//view the total size of the directory or file
[Email protected]/]# du-sh/tmp
164k/tmp
[Email protected] tmp]# Du-sh 1.txt
8.0K 1.txt
011. View Directory Permissions: Ls–ld directory Name
[Email protected] tmp]# Ls-ld perl
Drwxr-xr-x 2 root root 4096 Mar 12:39 Perl
View permissions for files under directory: LS–LR directory name
[Email protected] tmp]# LS-LR perl
Total 24
-rwxr-xr-x 1 root root 12:39 test2.pl
-rw-r--r--1 root root 12:38 test1.pl
-rw-r--r--1 root root 12:38 helloworld.pl
Change the permissions of the directory: chmod the corresponding permissions directory name/
Change directory and its subdirectories and file permissions: Chmod–r corresponding permissions directory name/
012. Get all Current login information
[[email protected]/]# users
Root
[email protected]/]# who
Root PTS/1 Mar 20 11:42 (192.168.0.66)
[Email protected]/]# W
15:34:43 up 3:57, 1 user, Load average:0.00, 0.00, 0.00
USER TTY from [email protected] IDLE jcpu PCPU
Root pts/1 192.168.0.66 11:42 0.00s 0.14s 0.00s W
013. How many accounts are there in the system?
# wc/etc/passwd-l
36/etc/passwd
014. Start and stop Apache services
#/etc/init.d/httpd Start//Startup httpd Service
#/etc/init.d/httpd Stop//close httpd service
#/etc/init.d/httpd Restart//Restart HTTPD service
To start the Web service automatically:
If you need to allow the HTTPD service to load automatically as the system starts, you can execute the "NTSYSV" command to start the service configuration program, locate the "httpd" service, precede it with an asterisk (*), and then choose OK.
The master configuration file for Apache is the httpd.conf default path:/etc/httpd/conf/httpd.conf
015. Start and stop Tomcat services
#/ETC/RC.D/INIT.D/TOMCAT5 Start Tomcat Service
#/ETC/RC.D/INIT.D/TOMCAT5 Stop Stop Tomcat Service
#/ETC/RC.D/INIT.D/TOMCAT5 Restart Restart Omcat service
To start the Tomcat service automatically:
If you need to have the Tomcat service load automatically as the system starts, you can execute the "NTSYSV" command to start the service configuration program, locate the "TOMCAT5" service, precede it with an asterisk (*), and then choose OK.
016. iptables Firewall
Turn off the firewall: Execute the "NTSYSV" command to start the Service configurator and cancel the "*" number before the "iptables" service.
If the firewall is turned on, how to open the TCP protocol 80 port: iptables-i input-p TCP--dport 80-j ACCEPT
Turn off SELinux:
#vi/etc/selinux/config
# This file controls the state of the SELinux on the system.
# selinux= can take one of these three values:
# Enforcing-selinux security policy is enforced.
# Permissive-selinux Prints warnings instead of enforcing.
# Disabled-selinux is fully disabled.
selinux=disabled #这样就把SELINUX服务器关掉了, please restart the system;
Linux daily use command Daquan