linux common commands Daquan, linux common commands (command) gave you tidy up

Common commands

ls displays the file or directory

 -l           列出文件详细信息l(list)

 -a          列出当前目录下所有文件及目录,包括隐藏的a(all)

Create a directory mkdir

 -p           创建目录,若无父目录,则创建p(parent)

cd Change directory

Create an empty file touch

echo to create a file with content.

cat view the file contents

cp copy

mv move or rename

rm delete files

 -r            递归删除,可删除子目录及文件

 -f            强制删除

find search for a file in the file system

wc statistics the number of rows of text, words, characters

grep search for a string in a text file

rmdir to delete empty directories

display the directory tree structure tree, tree packages to install

pwd displays the current directory

ln create a link file

more, less display text paging file contents

head, tail displays the file header, footer content

ctrl + alt + F1 command fullscreen

System Management Commands

stat displays detailed information of the specified file, and more than ls

who show online users log in

The current user displays whoami

hostname show hostname

uname information display system

dynamically displays the current top most resource-intensive process information

ps display instantaneous process status ps -aux

Check directory size du du -h / home directory information with a display unit

df view disk size df -h with displays disk information

Check ifconfig network conditions

ping test network connectivity

netstat displays network status information

man command will not be used, such as looking for a man: man ls

clear clear screen

The rename alias command: alias showmeit = "ps -aux", the use of additional release unaliax showmeit

kill kill the process, you can view the process id with ps or top command, then use the kill command to kill the process.

Compression packing related commands

gzip:

bzip2:

tar: compression packing

 -c              归档文件

 -x              压缩文件

 -z              gzip压缩文件

 -j              bzip2压缩文件

 -v              显示压缩或解压缩过程 v(view)

 -f              使用档名

Example:

tar -cvf /home/abc.tar / home / abc packaging only, not compressed

tar -zcvf /home/abc.tar.gz / home / abc packaged and compressed with gzip

tar -jcvf /home/abc.tar.bz2 / home / abc packaged and compressed by bzip2

Of course, if you want to decompress, directly replace the above command tar -cvf / tar -zcvf / tar -jcvf the "c" into "x" on it.

Shutdown / reboot the machine

shutdown

 -r             关机重启

 -h             关机不重启

 now          立刻关机

halt shutdown

reboot reboot

Linux Pipeline

The standard output of a command as standard input of another command. That is the number of command used in combination, the result of a previous command except a command.

Example: grep -r "close" / home / * | more look at all the files in the home directory, including close the file, and paging output.

Linux package management

dpkg (Debian Package) management tools, to .deb package name suffix. This method is suitable for networked systems can not be the case.

For example, the command to install tree installation package, first tree.deb spread Linux system. And then use the following command to install.

sudo dpkg -i tree_1.5.3-1_i386.deb install software

sudo dpkg -r tree uninstall software

Note: The tree.deb spread Linux system, there are a number of ways. VMwareTool, using the way of mounting; winSCP using tools;

APT (Advanced Packaging Tool) advanced software tools. This method is suitable where the system can be connected to the Internet.

Still an example to tree

sudo apt-get install tree 安装tree

sudo apt-get remove tree 卸载tree

sudo apt-get update update software

sudo apt-get upgrade

The .rpm file into .deb files

.rpm format RedHat software used. Can not be directly used in Ubuntu, you need to convert it.

sudo alien abc.rpm

Use vim

vim three modes: command mode, insert mode, edit mode. ESC or use i or: to switch modes.

In command mode:

: Q Quit

: Q Force Quit!

: Wq to save and exit

: Set number display line numbers

: Set nonumber hide line numbers

/ Apache apache find a skip over the n press, shift + n in a document

yyp cursor line copy, and paste

h (left one character ←), j (next line ↓), k (upper row ↑), l (right one character →)

User and user group management

/ Etc / passwd to store user account

/ Etc / group account storage group

/ Etc / shadow to store user account password

/ Etc / gshadow store user group account password

useradd username

userdel username

adduser username

groupadd group name

groupdel group name

passwd root password to the root

su root

su - root

/ Etc / profile system environment variables

bash_profile user environment variables

.bashrc user environment variables

su user switch user, loading a configuration file .bashrc

su - user switch user, loading a configuration file / etc / profile, loading bash_profile

Change the file users and user groups

sudo chown [-R] owner[:group] {File|Directory}

For example: also to jdk-7u21-linux-i586.tar.gz example. Hadoop user belongs, group hadoop

To switch users and groups this document belongs. You can use the command.

sudo chown root:root jdk-7u21-linux-i586.tar.gz

File permissions management

Three basic permissions

R represents 4 readings

W Write Values ​​are expressed as 2

Values ​​are expressed as X-executable 1

-rw-rw-r-- total of ten characters, divided into four sections.

The first character "-" indicates a regular file; this position may also appear "l" link; "d" indicates a directory

The second three or four characters "rw-" represents the rights of the current user belongs. Therefore, values ​​are expressed as a 4 + 2 = 6

The first five hundred sixty-seven character "rw-" represents the rights of the current belongs. Therefore, values ​​are expressed as a 4 + 2 = 6

The eighth ninety character "r--" expressed permissions to other users. Therefore, as represented by the value 2

So permission to operate this file is expressed as a numerical value 662

Change Permissions

sudo chmod [u belongs to the user group belong g o all users other users a] [+ Permissions increase - decrease permission] [rwx] directory name

For example: There is a file filename, permissions "-rw-r ---- x", the permission value to "-rwxrw-rx", as represented by the value 765

sudo chmod u+x g+w o+r filename

The above example can be expressed numerically

sudo chmod 765 filename

Guess you like

Origin blog.51cto.com/14422201/2415120