Common Linux commands,

Source: Internet
Author: User

Common Linux commands,
1. The most critical command

Man
Echo

2. directory file operation commands

Ls: view the file information or file information in the directory
Dir:
Pwd: print the current path
Cd: Change path
Mkdir: Create path
Rmdir: delete path
Cp: copy a file or directory
Mv: Move or rename a file or directory
Rm: delete a file or directory
Tree: output the file directory tree under this directory

3. View File Content

Cat:
More:
Less:
Head:
Tail:
Wc: number of characters, number of words, and number of lines in the Statistical File

4. User Management

Useradd: Add a user
Groupadd:
Userdel: delete a user
Groupdel
Passwd: set a password for the user
Usermod: change user settings
Su: User Switching
Finger root: View user information
Finger: view all user information
Last: User Logon in the last month
Id: print the UID and GID of the user.
Users:
Groups:
Who: List active users
Whoami:
Who am I:
W:
/Etc/default/useradd: default setting file when adding a user
/Etc/profile
/Etc/bashrc
~ /. Bashrc
~ /. Bash_profile

5. Command history

History
!! : Execute the last command

6. Create a connection

Ln a B: create hard link B for
Ln-s a B: Create a symbolic link for a (symbolic link) B

7. Process Management

Top view post-body processes to monitor system performance
Top-d 2: refresh every 2 seconds
Top-d 2-p 3690 view a PID
Top-B-n 2>/tmp/top.txt refresh the top information twice and output the result to/tmp/top.txt.
Ps view Process status
Free-m to view system memory usage
Uptime: system boot time

8. file comparison command

Diff
Cmp

9. Shutdown and restart

Shutdown [-t seconds] [-rkhncf] time [Warning Information]
Shutdown-h now shut down immediately, equivalent to halt
Shutdown-r now restarts immediately, equivalent to reboot
Dmesg | more
Clear Screen

10. Network commands

Ifconfig display or view network devices
/Etc/init. d/network restart: restart the network service (NIC)
The network IP configuration file is:/etc/sysconfig/network-script/ifcfg-eth0
Ifdown eth0 disable Nic
Ifup eth0 enable Nic
Route-n view route table
Routeadd-net 192.168.2.1 netmask 255.255.255.0 dev eth0
Netstat: View network connection status
Traceroute
Hostname: displays the host name.
Hostname-I: displays the IP address of the current host name

11. System Integration Management menu

Setup: System Service management commands
Ntsysv; Set system services

12. RPM software package management

Rpm-ivh xxx. rpm installation rpm package
Rpm-qa -- last | less: displays installed packages based on the installation date
Rpm-qa | grep mysql-I query whether the mysql package is installed (-I, case-insensitive)
Rpm-e Delete the installed software package
Rpm-e mysql * -- nodpes
Forcibly Delete related software packages
Rpm -- test installation
Run rpm-qi to query mysql package instructions
Run rpm-qpl xxx. rpm to view the content in the rpm package.
Rpm-qc [d] configuration file and description file
Rpm-Uvh upgrade and Installation
Rpmbuild -- bb SPECS/xxx. spec reinstall to compile xxx. spec into an rpm package.
Rpmbuild -- rebuild packagename. src. rpm re-compile. src. rpm into an rpm package.

13. Real-time communication

Write: Send a mail to a specified user
Write username
Talk:
Wall: send emails to everyone

14. File Ownership or permission management

Chown: Change the file owner
Chgrp: Change the file group
Chmod: changes the read and write permissions of files.
Umask: Change the default permissions of files and directories in the system

15. Pipeline (pipe)

Pipeline: Use the output of the previous command as the input of another command
Ls-la | more

16. Redirection

Write the output of a command into a file or file handle
Ls-la> filecontents.txt

17. Search for files

Locate:
Find:
Which:
Whereis:

18. source program compilation process

./Configure Check System Information
./Configure -- help | more provides configure help information
Make clean clear the files left before
Make Compilation
Make install Installation
Check the README/INSTALL file description during installation.

19. File compression command

*. Z compress compressed files
*. Bz2 bzip2 files compressed by the program
*. Gz gzip compressed files
* The files packaged by the. tar program are not compressed.
* .Tar.gz tar files are compressed by gzip.
Compress filename. Z compressed file
Compress-d filename. Z unzip the file
Gzip filename filename.gz compressed file
Gzip-d filename.gz unzip the file
Zcat filename.gz
Bzip2-z filename compressed file
Bzip2-d filename.bz2 unzip the file
Bzcat filename.bz2 view compressed file content
Tar-cvf filename.tar directory_name File Archive
Tar xvf filename.tar unbind the package
Tar xzvf filename.tar.gz unzip and unpackage
Tar xjvf filename.tar.bz2 unzip and unpackage
Tar ztvf filename.tar.gz view tar content

20. wildcard (wildcard character)

? : Indicates that the location can be any single character
*: Indicates that the location can be any number of characters.
[Charset]: can replace any single character in charset
For example
[Cc] h can represent Ch and ch respectively.
[A-z] can replace any single lowercase letter. [a-zA-Z] represents any letter.
Rm a *. out indicates that all files whose names start with a and whose extension is. out are deleted.
Ls img-00001-52.16.jpg?img1.jpg, img2.jpg, img3.jpg, img4.jpg, img5.jpg

21. Linux directory Architecture

/Root directory
/Bin common command storage directory, binary file
/Boot stores the files that must be read when the system starts, including the kernel.
/Boot/grub/menu. lst GRUB settings
/Boot/vmlinuz Kernel
/Boot/initrd kernel unzipping the required RAM Disk
/Dev system peripheral devices
/Etc system configuration files and subdirectories, including network configuration files, file systems, X system configuration files, device configuration information, user information, etc.
/Etc/DIR_COLORS set color
/Etc/hostname: Set the node name
/Etc/networking only yes indicates that the network exists
The/etc/host. conf file describes how your system queries node names.
/Etc/hosts


/Etc/hosts. allow sets the list of machines allowed to use inetd
The/etc/hosts. deny setting does not allow inetd machines.
/Etc/hosts. equiv set the name of the client without password access

/Etc/inetd. conf: configure the system network daemon inetd.
/Etc/gateways
/Etc/protocols: Set the protocols supported by the system
The/etc/named. conf system is used as the configuration file of the DNS server.
/Etc/sysconfig/network/scripts/ifcfg-eth0 set IP/MAC and other information
/Etc/resolv. conf set DNS
/Etc/X11 X Window configuration file
/Etc/fstab records the file system to be loaded upon startup

/Etc/inittab: Set the runlevel to which the init process enters when the system starts.

/Etc/issue records information displayed before Logon

/Etc/group: Set the user's group name and related information
/Etc/passwd Set User Account Information
/Etc/shadow user password information

/Etc/sudoers can be the configuration file of the sudo command
/Etc/securetty set the terminal that the root user can log on
/Etc/login. defs

/Etc/exports: sets the NFS System
/Etc/init. d/stores the preset STARTUP script of the Automatic startup process
/Etc/xinetd. d/stores the setting files of various services managed by super daemon
Additional parameter settings for the/etc/modprobe. conf kernel module
/Etc/syslog. conf System Log Setting File

/Home common user home directory
The function library used by the/lib or/lib64 system. The system dynamically links the shared library.
/Lib/modules kernel related modules
/Var/lib/rpm package installation

/Lost + found: When an abnormal system error occurs, some lost fragments are placed in this directory.
/Mnt external device mount point
/Media is similar to/mnt

/Opt additional software installed on the host

/Proc virtual directory, memory ing, storage system information
/Proc/version kernel version
/Proc/sys/kernel system kernel function

/Root system administrator's home directory
/System management commands that the sbin system administrator can execute
/Srv file directories required for these services after some services are started
/Tmp: A common user or a program being executed to store temporary files
/Usr Directory, which stores applications and files
/Usr/X11R6 X-window directory

/Usr/src Linux source code
/Usr/include system header file
/Usr/openwin: store SUN's OpenWin
/Usr/share/man online user manual
/Usr/bin: binary file directory executed by the user
/Usr/local/bin: binary file directory executed by the user
Function library used by/usr/lib
/Usr/local/lib system function library
/Usr/sbin commands that can be executed by the system administrator
/Usr/local/sbin commands that can be executed by the system administrator

/Var log files
/Var/log/secure record the information of the System Access File
/Var/log/wtmp record login user information
/Var/log/messages system error message
/Var/log/boot. log records the startup or shutdown information displayed when the system is started or when some services are started.
/Var/log/maillog records user records for email access or exchange
/Var/log/cron record the contents of the crontab Service
/Var/log/httpd,/var/log/news,/var/log/mysqld. log,/var/log/samba,/var/log/procmail. log different network service information

22. runlevel level

0: system shutdown status
1: single-user working status, root permission, used for system maintenance, remote login prohibited
2: multi-user status (no NFS)
3: full multi-user status (with NFS). log on to the console and go to command line mode.
4: The system is not used, reserved
5: X11 console. log on to the console and enter the GUI mode.
6: The system is shut down and restarted normally. The default running level cannot be 6; otherwise, the system cannot be started normally.

23. Common BASH Variables

$ HISTFILE: A file used to store historical commands
$ HISTSIZE: size of the historical command list
$ HOME: HOME Directory of the current user
$ OLDPWD: previous directory
$ PATH: bash searches for executable file search paths
$ PS1: the first-level prompt of the command line
$ PS2: Command Line second-level prompt
$ PWD: current working directory
$ SECONDS: The duration after the current shell starts, in SECONDS

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.