Linux Common commands

Source: Internet
Author: User
Tags clear screen log log system log unpack rpmbuild

1. The most critical command

Mans
Echo

2. Directory File Operations Command

LS: View the file information or file information under the directory
Dir
PWD: Print the current path
CD: Change path
mkdir: Creating a path
RmDir: Delete Path
CP: Copying Files or directories
MV: Moving files or directories, or renaming
RM: Deleting files or directories
Tree: Output file directory trees in this directory

3. View the contents of a file

Cat
More
Less
Head
Tail
WC: Statistics on the number of characters, words and lines of a file

4. User Management

Useradd: Adding users
Groupadd:
Userdel: Deleting users
Groupdel
PASSWD: Set password for user
usermod: change user settings
SU: User Toggle
finger root: View a user profile
last: User login for the last one months
ID: Print user's UID and GID
users:
groups:
who: List active users
whoami:
who am I:
w:
/etc/default/useradd: Default settings file when adding users
Span style= "font-size:16px" >/etc/profile
/ETC/BASHRC
~/.BASHRC
~/.bash_profile

5. Command history

History
!! : Executes the last command

6. Create a connection

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

7. Process Management

Top view the back-body process 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 output of top information refresh two times to/tmp/top.txt
PS View progress Status
Free-m Viewing system memory usage
Uptime: System Boot time

8. File Comparison command

Diff
Cmp

9. Shutdown and restart

Shutdown [-t number of seconds] [-RKHNCF] time [warning message]
Shutdown-h now shuts down immediately, equivalent to halt
Shutdown-r now restarts immediately, equivalent to reboot
DMESG | More View boot information
Clear Clear Screen

10. Network Commands

Ifconfig display or view network devices
/etc/init.d/network Restart: Restart Network Service (NIC)
The network IP configuration file is:/etc/sysconfig/network-script/ifcfg-eth0
Ifdown eth0 turn off the NIC
Ifup eth0 Open NIC
Route-n Viewing the routing table
Routeadd-net 192.168.2.1 netmask 255.255.255.0 Dev eth0
Netstat: View network connection Status
Traceroute
Hostname: Display host name
Hostname-i: Displays the IP of the current host name

11. System Integration Management Menu

Setup: System Services Administration commands
NTSYSV; setting up system services

RPM Package Management

RPM-IVH xxx.rpm Installation RPM Package
Rpm-qa--last | Less shows installed packages based on installation date
RPM-QA |grep mysql-i Query system installs MySQL package (-I, ignoring case)
RPM-E Removing installed Packages
RPM-E mysql*--nodpes
Force removal of related packages
RPM--test Test Installation
Rpm-qi Query MySQL Package description information
RPM-QPL xxx.rpm See what the RPM package contains.
RPM-QC[D] Profiles and profiles
RPM-UVH Upgrade Installation
Rpmbuild--BB Specs/xxx.spec re-installed the Xxx.spec into the RPM package.
Rpmbuild--rebuild packagename.src.rpm to re-compile the. src.rpm into RPM packages.

13. Real-Time communication

Write: Send a letter to the specified user
Write username
Talk
Wall: Send Letters to everyone

14. File ownership or rights Management

Chown: Change file Owner
Chgrp: Changing the genus Group of files
chmod: Change the file read/write, execute permissions
Umask: Change the default permissions for files and directories under the system

15. Piping (pipe)

Pipe: The output of the previous command as input to another command
Ls-la | More

16. Redirection

Writes the output of a command to a file or to a file handle
Ls-la > Filecontents.txt

17. Find Files

Locate
Find
Which:
Whereis:

18. The compilation process of the source program

./configure Check System Information
./configure--help | More information about Configure Help
Make clean clears the files left before
Make compilation
Make install Installation
View the Readme/install file for more information during installation

19. File Compression Command

*. Z Compress Program Compressed files
*.BZ2 BZIP2 Program Compressed files
*.gz gzip Program Compressed files
*.tar Tar program packaged files that have not been compressed
*.tar.gz tar program packaged files and gzip compressed processing
compress filename filename. Z compressed file
compress-d filename. Z Extract File
gzip filename filename.gz compressed file
gzip-d Filename.gz Extract File
zcat filename.gz View Compressed file
bzip2- z FileName Compressed file
bzip2-d filename.bz2 extract file
bzcat FILENAME.BZ2 Viewing compressed file contents
TAR-CVF filename.tar directory_name file archive
tar xvf Filename.tar Unpack the package
tar xzvf filename.tar.gz extract and unpack
tar xjvf filename.tar.bz2 extract and unpack
tar ZTVF filename.tar.gz View tar content

20. Wildcard characters (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 the CharSet
For example
[Cc]h can represent CH and ch, respectively.
[A-z] can replace any single lowercase letter, [a-za-z] denotes any letter
RM a*.out means to delete all files that begin with a with an. out extension
LS img-[1-5].jpg represents img1.jpg, Img2.jpg, Img3.jpg, Img4.jpg, img5.jpg

. Linux Directory Architecture

/root directory
/bin common commands stored directories, binary file
/boot the file that must be read when the system starts, including the kernel
/boot/grub/menu.lst Grub Settings
Span style= "font-size:16px" >/boot/vmlinuz kernel
/BOOT/INITRD kernel extract required Ram Disk
Span style= "font-size:16px" >/dev system Peripherals
/etc system-related profiles and subdirectories, including network profiles, file systems, X-System configuration files, Device configuration information, user information, and so on
/etc/dir_colors set color
/etc/ Hostname Set node name
/etc/networking only yes indicates network exists
/ The etc/host.conf file describes how the user's system queries the node name
/etc/hosts set the corresponding table for machine IP and name


/etc/hosts.allow setting the list of machines allowed to use inetd
/etc/hosts.deny setting a list of machines that do not allow the use of inetd
/ETC/HOSTS.EQUIV setting a client name without password access

/etc/inetd.conf setting the configuration of the System network daemon inetd
/etc/gateways setting the configuration of the router
/etc/protocols setting System-supported protocols
/etc/named.conf system as a DNS server configuration file
/etc/sysconfig/network/scripts/ifcfg-eth0 setting up Ip/mac and other information
/etc/resolv.conf Setting up DNS
/etc/x11 X Window's configuration file
/etc/fstab record the file system to be loaded on boot

/etc/inittab set the init process to enter what kind of runlevel when the system starts

/etc/issue record the information displayed before the user logs in

/etc/group Setting the user's group name and related information
/ETC/PASSWD Setting user account information
/etc/shadow User password information

/etc/sudoers can be the sudo command configuration file
/etc/securetty set the terminal to which the root user can log in
/etc/login.defs Setting the default configuration for all users when they log on

/etc/exports setting up an NFS system
/etc/init.d/startup script to store a preset autostart process
/etc/xinetd.d/Storage settings file for Super Daemon Managed Services
/etc/modprobe.conf Kernel module additional parameter settings
/etc/syslog.conf System Log settings file

/home directory for ordinary users
/lib or/lib64 system will use the library, System dynamic Link shared library
/lib/modules Kernel related modules
/VAR/LIB/RPM RPM Package Installation Office

/lost+found system Abnormal error occurs, some missing fragments are placed in the directory
/MNT mount points for external devices
/media is similar to/mnt

Additional software installed on the/OPT host

/proc virtual directory, memory mapping, storage System Information
/proc/version kernel version
/proc/sys/kernel System kernel functions

/root system Administrator's home directory
/sbin system Administration instructions for system administrators
Span style= "font-size:16px" >/srv after some services are started, the file directories required by these services
/tmp where the general user or the executing program holds temporary files
/usr largest directory, storing 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
Span style= "font-size:16px" >/usr/bin user executed binary file directory
/usr/local/bin The binary file directory that the user executes
/usr/lib the function library used by the system
/usr/ Local/lib function libraries used by the system
/usr/sbin system administrators to execute instructions
/usr /local/sbin the system administrator can execute the directive

/var log files, etc.
/var/log/secure record log in system Access file information
/var/log/wtmp logging logged-in user information
/var/log/messages error message on system
/var/log/boot.log Log on or when some services start, the startup or shutdown information that is displayed
/var/log/maillog recording of user records for mail access or correspondence
/var/log/cron recording 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

level of RunLevel

0: System shutdown status
1: Single user working status, root privileges, for system maintenance, no remote login
2: Multi-user status (no NFS)
3: Full multi-user status (with NFS), login to console command line mode
4: System not used, reserved
5:x11 Console, login and enter GUI mode
6: The system shuts down and restarts normally, the default run level cannot be 6, otherwise it will not start normally

. Bash Common Variables

$HISTFILE: The file used to store the history command
$HISTSIZE: The size of the history command list
$HOME: Home directory for the current user
$OLDPWD: Previous Directory
$PATH: Bash search path for executable files
$PS 1: One-level prompt at the command line
$PS 2: Two-level prompt at the command line
$PWD: Current Working directory
$SECONDS: The length of time, in seconds, after the current shell has started

Linux Common commands

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.