Common linux commands

Source: Internet
Author: User
Tags domain name server
Common linux commands-general Linux technology-Linux technology and application information. For details, refer to the following section. As the graphic operating environment is prevalent today, linux commands do not seem to have much significance for general users. I believe that few people will like to face a black screen all day, give up the gorgeous operation interface, and use obscure commands to operate their own computers. But sometimes some commands are inevitable. The following lists the usage of some common commands for your reference.

-. System Management
[Bg]
Note: place the program in the background for running.

Syntax: bg [job]

Parameter: job ID.

[Export]
Description: sets or displays environment variables.

Syntax: export [-fnp] [variable name] = [variable setting value]

Parameter:-f indicates the function name in [variable name].-n indicates the deletion of the specified variable. The variable is not actually deleted, but is not output to the execution environment of subsequent commands; -p: list all environment variables that the shell assigns to the program.

[Fg]
Note: Switch the program or command to the foreground for execution.

Syntax: fg [job]

Parameter: job ID.

[Groupadd]
Creates a user group.

Syntax: groupadd [-g gid [-o] [-r] [-f] group name

Parameter:-g gid specifies the group ID-GID value;-o reuse group ID;-r is used to create system accounts;-f forces the creation of new user groups.

[Groupdel]
Delete a user group.

Syntax: groupdel group name

[Groupmod]
Modify user group information.

Syntax: groupmod [-g gid [-o] [-n group_name] group name

Parameter:-g gid re-specifies the group ID value;-o re-uses the group ID;-n group_name changes the user group name.

[Shutdown]
Disable the computer.

Syntax: shutdown [-r] [-h] [-I] [-k] [-m] [-t]

Parameter:-r: restart after Shutdown;-h: power supply disconnection after Shutdown;-I: system information displayed when shutdown;-k: not actually shutdown, only send a warning message to each consumer;-m: Change the system to single-user mode;-t: Tell the init program how long it will be shut down before it changes to another running level;-c: cancel the current shutdown operation;-F: Force fsck when the computer is restarted;-time: set the time before shutdown.

[Kill]
Note: sending a signal to a running program (process) may lead to program termination.

Syntax: kill [-s <消息名或编号> ] [Program]

Kill [-I <消息编号> ]

Parameter:-s <消息名或编号> Specifies the message to be sent. The process Number of the [Program] program can be obtained using the ps command;-I <消息编号> Lists message names. If a message number is specified, only the message name is displayed.

[Lsmod]
Description: displays the kernel modules loaded into the system.

Syntax: lsmod

[Modinfo]
Description: displays kernel module information.

Syntax: modinfo [-adphV] [-f format_string] module File Name

Parameter:-a indicates the author of the kernel module;-d indicates the description of the kernel module;-p indicates the parameters supported by the kernel module; and-h indicates the help information; -V indicates the version information.-f format_string indicates a string of any format, which is used to extract module information from the ELF part of module_file.

[Ps]
Views the currently running process.

Syntax: ps [-aeHuwx] [-- group <用户组名> ] [-- Tty <终端号> ] [-- User <用户账号名> ]

Parameters:-a indicates the processes executed on all terminals;-e indicates all programs;-H indicates the tree structure, indicating the relationship between processes; -u displays the status in the user-based format;-w uses a wide display mode;-x displays all programs without distinguishing terminals; -- group <用户组名> Only processes started by the specified user group are displayed. -- tty <终端号> Only processes started on the specified terminal are displayed; -- user <用户账号名> Only processes started by the specified user are displayed.

[Su]
Note: The user identity is changed temporarily.

Syntax: su [-fl] [-c <指令> ] [User Account]

Parameter:-f if you log on with another user account, you will not be able to read the user's account. profile, etc.-l the working directory is also changed after the user account is changed, just like the New Login of the user account;-c <指令> After executing the specified command, return to the original user account.

[Who]
Note: All user information that has been logged on to the system is displayed.

Syntax: who [-Hiq]

Parameter:-H indicates the title of each information.-I indicates the user's idle time. There is no action within one minute and it is marked as ". ", no action within one day, marked as" old ";-q only shows the total number of users currently logged on to the system.

Ii. file and directory operations
[Cat]
Note: The content of one or more files is displayed on the screen.

Syntax: cat [-bEn] [file…]

Parameter:-B adds the line number (starting from 1) at the beginning of each line (except for empty rows);-E adds the symbol "S |" at the end of each line "; -n: add a line number (starting from 1) at the beginning of each line. [file…] List of file names to display.

[Cd]
Note: Switch the current directory.

Syntax: cd [destination Directory]

Parameter: the name of the [target directory] Directory to be switched to. It can be a relative or absolute path.

[Chgrp]
Description: modifies the user group to which a file or directory belongs.

Syntax: chgrp [-fR] [user group] [file/directory name…]

Chgrp [-fR] [-- reference = <参考文件 目录> ] [File/directory name…]

Parameter:-f does not display the error message. All files and subdirectories in the specified directory of-R will be modified to the specified user group. -- reference = <参考文件 目录> Set the user group to which the specified file or directory belongs to and the user group to which the specified file or directory belongs.

[Chmod]
Note: Modify the file/directory permissions.

Syntax: chmod [-fR] [ <权限范围> +/-/= <权限设置> ,…] [File/directory…]

Chmod [-fR] [digit code] [file/directory…]

Chmod [-fR] [-- reference = <参考文件 目录> ] [File/directory…]

Parameter:-f does not display the error message.-R specifies that the permissions of all files and subdirectories under the directory will be modified; <权限范围> + <权限设置> : Enable corresponding permissions? Lt; permission range>- <权限设置> : Disable the corresponding permissions; <权限范围> = <权限设置> : Set the corresponding permissions; -- reference = <参考文件 目录> Set all the permissions of the specified file or directory to the same as those of the reference file/directory; <权限范围> Including u: owner of the file/directory; g: user group to which the file/directory belongs; o: other users; a: All users, that is, ugo; <权限设置> Including r: Read Permission, corresponding digit code: "4"; w: Write Permission, corresponding digit code: "2"; x: Execution permission, the corresponding digit code is "1";-: The corresponding digit code is "0 ".

[Chown]
Modify the owner of a file/directory and the user group.

Syntax: chown [-fR] [owner <所属用户?gt;][文件 目录…]

Parameter:-f does not display the error message. The owner and user group of all files and subdirectories in the directory specified by-R will be modified.

[Cp]
Note: Copy files or directories.

Syntax: cp [-bfipR] [-S <备份字尾字符串> ] [Source file/directory…] [Target file/directory…]

Parameter:-B. When copying a file, automatic backup is performed before the target file is to be deleted or overwritten. The backup file name is the original file name + the specified backup string at the end of the word;-f indicates the forced copy of the file or directory, whether or not the target file or directory exists;-I first asks the user when the original file needs to be overwritten during file copy; -p retains the attributes of the source file or directory (owner, user group, permission, and time). All files and subdirectories in the directory specified by-R will be copied.

[Df]
Views partition usage and related file systems.

Syntax: df [-ahkmT] [file/device]

Parameters:-a displays all file systems;-h displays usage in a more intuitive manner;-k is measured in KB;-m is measured in MB; -T indicates the type of the file system. [file/device] the disk is represented by a device file. If a file is provided, the disk where the file is located.

[Find]
Description: searches for a file or directory.

Syntax: find [directory…] [-Amin <分钟> ] [-Atime <24 hours>] [-ctime <24 hours>] [-cmin <分钟> ] [-Group <用户组名> ] [-Mmin <分钟> ] [-Mtime <24 hours>] [-name <样式> ] [-Print] [-user <用户名> ]

Parameter:-amin <分钟> Find the files or directories that have been accessed within the specified minute;-atime <24 hours> find the files or directories that have been accessed within the specified hour; -ctime <24 hours> searches for files or directories created within the specified hour.-cmin <分钟> Find the files or directories created within the specified minute;-group <用户组名> Find the files or directories belonging to the User Group;-mmin <分钟> Find the files or directories modified within the specified minute;-mtime <24 hours> find the files or directories modified within the specified hour;-name <样式> Find the file/directory name that matches the style.-print displays the search result on the screen.-user <用户名> Search for files or directories belonging to this user.


[Ls]
Description: lists the contents of directories, including the names of files and subdirectories.

Syntax: ls [-acGhlrRu] [-- color = <颜色方案> ] [-- Show-control-chars] [file/directory]

Parameters:-a displays all files and directories,-c sorts the files by the modification time, and-G does not display the user group information; -h: displays the file or directory size in units of KB, MB, and GB.-l displays detailed information, including the file size and modification time.-r reverse sorting; -R: lists all files and subdirectories in the specified directory.-u is sorted by the last access time. -- color = <颜色方案> Different colors are used to differentiate different content. -- show-control-chars is displayed when a control character is used. If a Chinese name is available, this parameter is used.

[Mkdir]
Creates a sub-directory.

Syntax: mkdir [-p] [-m <目录属性> ] [Directory name]

Parameter:-p if the upper-level directory of the directory to be created has not been created, create this level directory first;-m <目录属性> When creating a directory, set its directory permissions in the same format as the chmod command.

[Mount]
Attaches a file system to a specified directory.

Syntax: mount [-anrw] [-t <文件系统> ] [Device name] [loading point]

Parameter:-a is loaded to all devices described in/etc/fstab.-n is not recorded in the/etc/mtab file of the log file; -r: load the device in read-only mode;-w: load the device in read/write mode;-t <文件系统> Specifies the type of file system to load, including minix: the earliest File System in Linux; ext2: The most common file system in Linux; msdos: FAT16 of MS-DOS; vfat: FAT32 in Windows; nfs: Network File System; iso9660: CDROM file system format; ntfs: Windows NT file system; hpfs: OS/2 file system; auto: automatically checks the file system type; [load point] is actually a directory. Create an empty directory where the content is the file system content you load.

[Mv]
Note: Move or rename a file or directory.

Syntax: mv [-bfiu] [-S <字符串> ] [Source file or directory] [target file or directory]

Parameter:-B: when another file or directory needs to be overwritten, the backup is automatically backed up. The backup file name is the original file name and the string specified by the-S parameter is added. If this parameter is not set, "~" is added. -F if duplicate occurs, directly overwrite without backing up;-I always ask the user when the file or directory needs to be overwritten; -u if the file or directory to be overwritten is newer than the source file, the target file is not overwritten;-S <字符串> Specifies the string to be added after the backup file name.

Tip: when the target file or directory is in the same directory as the source file or directory, it becomes a renamed command.

Passwd]
Note: Set the user account password.

Syntax: passwd [-dlSu] [user name]

Parameter:-d: Delete the password;-l: Lock the account;-S: List password-related information;-u: Unlock the locked account; [user name] the user account for which the password is to be set, if this parameter is not specified, the password of the currently logged on user is set.

Note: This command can only be used by the root user.

[Rm]
Delete files and directories.

Syntax: rm [-fr]

Parameter:-f is forcibly deleted without inquiry.-r recursive processing deletes all files and subdirectories in the specified directory.

[Umount]
Note: reverse mount operations are performed to uninstall the file system.

Syntax: umount [-ar] [-t <文件系统类型> ] [File System]

Parameter:-a: unmount all file systems recorded in/etc/mtab;-r: If unmount fails, re-mount it to read-only mode;-t <文件系统类型> Only uninstall the specified type of file system; load point when the [File System] File System is mounted.

Iii. Network Communication
[Ifconfig]
Description: displays the status of network devices and sets network device properties.

Syntax: ifconfig [network device] [down up] [io_addr] [irq] [netmask <子网掩码> ] [IP address]

Parameter: [network device] indicates the name of the network device to be displayed or set, for example, eth0, the first Nic; down: stops the specified network device; up restarts the specified network device to the working status. [io_addr] sets the I/O address of the device; [irq] sets the IRQ address of the device; netmask <子网掩码> Sets the subnet mask of the device. [IP address] sets the IP address of the device.

[Netstat]
Description: displays the network status.

Syntax: netstat [-acCeFghilMnNoprstuvVwx] [- <网络类型> ] [-- Ip]

Parameters:-a: shows the sockets in all connections;-c: displays the network status continuously;-C: displays the cache information of the route configuration;-e: displays other network-related information;-F: displays FIB, this is the default value.-g displays the list of multiple broadcast user groups,-h online help,-I displays the list of network interfaces, and-l displays the Socket of the server in monitoring; -M indicates a disguised network connection;-n indicates that the IP address is used directly without passing through the Domain Name Server;-N indicates that the connection name of the network hardware peripheral device; and-o indicates that the timer is displayed; -p indicates the program identification code and program name using Socket;-r indicates the route table;-s indicates the statistical table of network work information; and-t indicates the connection of TCP transmission protocol; -u: displays the connections of UDP transmission protocol;-v: displays the command execution process;-w: displays the connections of RAW transmission protocol;-x: indicates-A unix;-. <网络类型> List the related addresses in the network connection; -- the ip parameter is-A inet.

[Ping]
Note: It can be used to check whether it can be connected to a host on the network.

Syntax: ping [-fn] [-c <连接次数> ] [-I <间隔时间> ] [-I <网络设备> ]

Parameter:-f generates a ping storm, which puts a serious burden on the network. It is only available to root users and can be used to collect statistics on Packet Loss and error rate.-n outputs only numerical values and does not attempt to obtain the host name; -I <间隔时间> Sets the interval between two Ping packets, in seconds.-I <网络设备> When the system has multiple devices, you can use this parameter to specify a network device.

[Traceroute]
Description: displays the path from the local host to the remote host.

Syntax: traceroute [-dFInrvx] [-f first_ttl] [-g gateway] [-I iface] [-m max_ttl] [-p port] [-q nqueries] [-s src_addr] [-t tos] [-w waittime] host [packetlen]

Parameter:-d allows interface-level debugging;-F allows flag separation;-I uses ICMP ECHO to respond to UDP datagram;-n directly uses IP addresses to display hop-by-hop addresses; -r bypasses the common route table and connects directly to the remote host;-x enables/disables packet check;-f first_ttl sets the TTL of the first packet to be sent, ranging from 1 ~ 256;-g gateway specifies a free source gateway, up to eight can be specified;-I iface sends data packets with the specified network interface; -m max_ttl: sets the maximum TTL value of the data packet to be sent out. The default value is 30.-p port sets the basic UDP port. The default value is 33434; -s scr_addr sets the IP address of the data packet sent by the local host;-t tos sets the service type of the data packet, valid range: 0 ~ 255, the default value is 0;-w waittime sets the time to wait for the returned data packet, in seconds.

4. Other commands
[Bzip2]
Note: bzip2is the compression tool for .bz2 files.

Syntax: bzip2 [-cdfkqstvVL] [-1 |-2 |-3 |-4 |-5 |-6 |-7 |-8 |-9] [filename]

Parameter:-c: compress/decompress the file to the standard output device;-d: Decompress;-f: if the existing file and the decompressed output file are duplicated, overwrite the existing file; -k retains the input file (the source file) after decompression;-q disables unnecessary warning information;-s reduces the memory required for running the command;-t checks the integrity of the file; -v: displays details when working.-V: displays version information.-L: displays License information.-1 ~ -9 set the compressed block size, that is, kb ~ The compression process is 900 kb.

[Grep]
Description: searches for matching strings in the file.

Syntax: grep [-qrv] [style] [file/directory name…]

Parameter:-q does not display any information about the intermediate process. If-r uses this option, it searches for the content of all files and subdirectories in the specified directory, that is, to find columns that do not contain strings specified by "style.

[Gzip]
Note: To Compress/decompress a file, the generated file is suffixed with ". GZ.

Syntax: gzip [-dfl] [- <压缩效率> ] [File…]

Gzip [-dflr] [- <压缩效率> ] [Directory]

Parameter description:-d extract;-f forcibly compress the file and directly overwrite the file with the same name;-l lists information about the compressed file, including the size, compression ratio, and file name before and after compression; -r: compress all files and subdirectories in the specified directory to this file ;- <压缩效率> Is a 1 ~ The smaller the number, the faster the compression, the larger the number and the higher the compression ratio.

[Tar]
Note: Create and restore backup files.

Syntax: tar [-Acdkvx] [-f <备份文件> ] [File/directory…]

Parameter:-A adds A file to an existing backup file;-c creates A backup file;-d compares the difference between the backup file and the current directory file;-k unlocks the backup file, do not overwrite existing files;-v displays the command execution process;-x restores the content in the backup file;-f <备份文件> Specifies the backup file name.

Finally, I would like to remind you that when you forget the syntax of a command, you can use man to obtain its usage information. For example, man ls. When you want to know the instructions for some operations, You can execute info to view its information page.
Related Article

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.