Linux routine instructions

Source: Internet
Author: User
Tags clear screen i18n nameserver

Linux routine instructions Daquan Java code www.2cto.com 001, routine maintenance commonly used query commands # top display system processes # clear screen information # cat/etc/redhat-release view system version information # cat/proc /version view system kernel version and other information # uname-a view system kernel and other information # cat/proc/cpuinfo view CPU information # cat/proc/meminfo view memory information # cat/proc/ swaps: View swap space information # getconf LONG_BIT: Check whether the CPU is 32-bit or 64-bit # dmidecode | more: View BIOS information. # Grep MemTotal/proc/meminfo view physical memory information # grep SwapTotal/proc/meminfo view swap space size # cat/etc/passwd view account information # cat/etc/shadow view password information # cat/etc/group, which users are included in each group, or # vigr # groups username to view which group the user belongs to # ps-aux to display all processes on the terminal, including processes of other users. # Ps-x displays the processes that do not control the terminal. # Ps-e shows all processes. # Ps-r only displays running processes. The free command can be used to view CPU usage information in the top-n1 command. 002. Change the startup interface to text mode (command mode), 3 to text mode, and 5 to graphic mode. # Vi/etc/inittab modify id: 5: initdefault: id: 3: initdefault: 003, modify the remote management of the command line Chinese garbled problem Red Hat Enterprise Linux default language encoding is "zh_CN.UTF-8", in X-Window desktop environment can be normal display of Chinese characters, however, if you perform remote management through SSH or Telnet, all Chinese characters will become garbled. # Vi/etc/sysconfig/i18n change LANG = "zh_CN.UTF-8" to LANG = "zh_CN.GB18030", after logging on again, the Chinese characters can be displayed normally. 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" system default English language, also supports 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 Nic 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 network 005, change host name # vi/etc/sysconfig/network rename hostname, and then restart. 006. In consideration of security issues, only normal accounts are allowed to log on remotely. root users are not allowed to log on remotely. Configure sshd to start sshd service:/etc/init. d/sshd start edit the/etc/ssh/sshd_config file, find the statement PermitRootLogin yes, and change yes to no. Restart the sshd service:/etc/init. d/sshd restart 007. disable unnecessary system services. To improve the running efficiency of the installed system, we recommend that you disable unnecessary system services, for example, cups, sendmail, isdn, smartd, iptables, pcmcia.... # Chkconfig cups off # chkconfig sendmail off # chkconfig isdn off # chkconfig smartd off # chkconfig iptables off # chkconfig pcmcia off 008. Modify the DNS standard format: nameserver DNS address # vi/etc/resolv. conf nameserver 192.168.0.36 nameserver 202.106.0.20: wq # Save and quit. # Service network restart # restart the network, view 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 190 M 8.4 M 172 M 5%/boot none 248 M 0 248 M 0%/dev/shm # df-h/home partition disk usage 010. view the Directory and the file size in the directory, or view the size of a single file # du-h directory or file [root @ eric68/] # du-h/tmp 12 K/tmp /. font-unix 8.0 K/tmp /. ICE-unix 12 K/tmp/ssh-wDIORJg370 36 K/tmp/test 164 K/tmp [root @ e Ric68 tmp] # du-h 1.txt 8.0 K 1.txt du-sh directory or file // view the total size of the directory or file [root @ eric68/] # du-sh/tmp 164 K /tmp [root @ eric68 tmp] # du-sh 1.txt 8.0 K 1.txt 011. view directory permissions: ls-ld directory name [root @ DB65 tmp] # ls-ld perl drwxr-xr-x 2 root 4096 Mar 26 perl permission to view files in the directory: ls-lr directory name [root @ DB65 tmp] # ls-lr perl total 24-rwxr-xr-x 1 root 24 Mar 26 12:39 test2.pl-rw-r -- 1 root 65 Mar 26 12:38 test1.pl-r W-r -- 1 root 44 Mar 26 12:38 helloworld. pl: Change the directory permission: chmod corresponding permission directory name/change the Directory and Its subdirectories and file permissions: chmod-R permission directory name/012. obtain the information of all current login users [root @ db80/] # users root [root @ db80/] # who root pts/1 Mar 20 (192.168.0.66) [root @ db80/] # w 15:34:43 up, 1 user, load average: 0.00, 0.00, 0.00 user tty from login @ idle jcpu pcpu what root pts/1 192.168.0.66 0.00 s 0.14 s 0.00 s w 013. How many accounts are there in the system? # Wc/etc/passwd-l 36/etc/passwd 014. start and Stop the apache service #/etc/init. d/httpd start // start the httpd service #/etc/init. d/httpd stop // disable the httpd service #/etc/init. d/httpd restart // restart the httpd service to automatically start the WEB service. To enable the httpd service to automatically load as the system starts, run the "ntsysv" command to start the service configuration program, find the "httpd" service, add an asterisk (*) to it, and select "OK. The main configuration file of Apache is httpd. default conf path:/etc/httpd/conf/httpd. conf 015. Start and Stop the Tomcat service #/etc/rc. d/init. d/tomcat5 start Tomcat service #/etc/rc. d/init. d/tomcat5 stop Tomcat service #/etc/rc. d/init. d/tomcat5 restart the omcat service to automatically start the Tomcat service. To enable the Tomcat service to automatically load as the system starts, run the "ntsysv" command to start the service configuration program, find the "Tomcat5" service, add an asterisk (*) to the front of it, and then select "OK. 016. Disable the firewall using Iptables: run the "ntsysv" command to start the service configuration program and cancel the "*" before the "iptables" service. If the firewall is enabled, How To Enable TCP port 80: iptables-I INPUT-p tcp -- dport 80-j ACCEPT to disable SELINUX: # vi/etc/selinux/config # This file controls the state of 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 # in this way, The SELINUX server is turned off. Please restart Dynamic System; # SELINUXTYPE = type of policy in use. possible values are: # targeted-Only targeted network daemons are protected. # strict-Full SELinux protection. SELINUXTYPE = targeted 017. Disable and respond to ping # echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all disable ping and ignore ICMP packets. # Echo 0>/proc/sys/net/ipv4/icmp_echo_ignore_all respond to ping. The above two settings expire after restart. If they are added to/etc/rc. local, they remain valid after restart. 018. Command for viewing historical records in history: # history Note: To view commands used previously, the maximum number of historical records is 1000 by default (in red hat ), you can modify the "HISTSIZE" parameter in "/etc/profile" to modify the default value to clear historical records. Command: # history-c immediately update the history file command: # history-w History record principle: when a user logs on to the system using bash, the command entered by the user will be put into a memory catch, and will be saved to ~ when the user logs out ~ /. In bash_history, The histroy-c command can be used to clear the command cache. That is to say, this user does not want to know what he has done, run history-c before exiting. View a user's history record: # history-w # history or # more. bash_history how to automatically back up a user's history record? 1. Create the history daily backup script # cd tmp # mkdir ericyi_history_backup # chown root ericyi_history_backup/# vi ericyihistorybackupdaily. sh success -----------------------------------------------------------------#! /Bin/bash day = 'date + % Y-% m-% d' basedir = "/tmp/ericyi_history_backup" cd/home/ericyi history-w cp. bash_history "$ basedir"/history. "$ day">/dev/null ----------------------------------------------------------------- how to record the command operation and system output after the user logs in? Add the following content to/etc/profile: -------------------------------------------------------------------------------- # log user input partition t test if [$ USER! = "Test"]; then SSHCLIENTIP = 'echo $ SSH_CLIENT | awk '{print $1 ;} ''userlogfilename =/tmp/$ {USER} _ 'date + "% Y % m % d % H % M" '_ from _ $ {SSHCLIENTIP }. log echo "ssh client info: "$ {SSH_CLIENT }>$ {USERLOGFILENAME} exec/usr/bin/script-a-f-q $ {USERLOGFILENAME} fi 127019, regular data backup in linux # chmod 700 backupdaily. sh // modify the permission. Run the command as ROOT # vi/et C/crontab // task plan # Add the following content: 10 1 *** root/etc/root/backupdaily. sh Note: run the script at 01:10 every day: wq save and exit. 020. What is the scheduled synchronization time in Linux? # Ntpdate 207.46.232.182: run the script on crontab periodically.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.