【Linux】Common operation commands in Linux

Original link: http://www.weixuehao.com/archives/25
Introduction to Linux and Ubuntu installation

Common commands

System management commands

Packaging and compression related commands

Shut down/restart the machine

Linux pipeline

Linux package management

vim use

User and user group management

File permission management

Daniel Notes - www.weixuehao.com

from: http://www.weixuehao.com/archives/25

Introduction to Linux and Ubuntu installation

of Linux, free and open source, multi-user multi-tasking system. There are several derivatives based on Linux. RedHat, Ubuntu, Debian

install VMware or VirtualBox virtual machines. For specific installation steps, find Baidu.

Install Ubuntu again. For specific installation steps, find Baidu.

After installation, you can see the directory structure of the Linux system, see the link http://www.cnblogs.com/laov/p/3409875.html





Common commands

ls show files or directories

     -l list file details l(list)

     -a List all files and directories in the current directory, including hidden a(all)

mkdir creation directory

     -p Create a directory, if there is no parent directory, create p(parent)

cd switch directory

touch Create an empty file

echo Create a file with content.

cat view file content

cp copy

mv move or rename

rm delete file

     -r delete recursively, delete subdirectories and files

     -f force delete

find search for a file in the file system

wc count the number of lines, words and characters

in the text grep in the text Find a string in the file

rmdir delete empty directory

tree tree structure display directory, need to install tree package

pwd display current directory

ln create link file

more, less paging display text file content

head, tail display file head and tail content

ctrl+alt +F1 Command line full screen mode



System management commands

stat shows the detailed information of the specified file, more detailed than ls

who shows the online login user

whoami shows the current operating user

hostname shows the hostname

uname shows the system information

top dynamically shows the current process information that consumes the most resources

ps shows the instantaneous process status ps -aux

du View the directory Size du -h /home with units to display directory information

df to view disk size df -h with units to display disk information

ifconfig to view network conditions

ping to test network connectivity

netstat to display network status

information ls

clear Clear the screen

alias Rename the command such as: alias showmeit="ps -aux", in addition to cancel using unaliax showmeit

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



Packaging and compression related commands

gzip:

bzip2:

tar: archive

     -c archive

     -x archive

     -z gzip archive

     -j bzip2 archive

     -v show compression or decompression process v(view)

     -f use filename

Example :

tar -cvf /home/abc .tar /home/abc package only, not compress

tar -zcvf /home/abc.tar.gz /home/abc package and compress with gzip

tar -jcvf /home/abc.tar.bz2 /home/abc package and use bzip2 Compression

Of course , if you want to decompress, just replace "c" in the above command tar -cvf / tar -zcvf / tar -jcvf with "x".



Shut down/restart the machine

shutdown

     -r Shut down and restart

     -h Shut down without restart

     now Shut down immediately

halt Shut down

reboot Restarts



the Linux

pipeline . Use the standard output of one command as the standard input of another command. That is, several commands are used in combination, and the latter command divides the result of the previous command.

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



Linux package management

dpkg (Debian Package) management tool, the package name is suffixed with .deb. This method is suitable when the system cannot be networked.

For example, to install the installation package of the tree command, first transfer tree.deb to the Linux system. 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 : There are many ways to transfer tree.deb to Linux system. VMwareTool, use the mount method; use winSCP tools, etc.;

APT (Advanced Packaging Tool) advanced software tools. This method is suitable when the system is able to connect to the Internet.

Still take tree as an example

sudo apt-get install tree install tree

sudo apt-get remove tree uninstall tree

sudo apt-get update update software

sudo apt-get upgrade       



converts .rpm files into .deb files

. rpm is the software format used by RedHat. It cannot be used directly under Ubuntu, so it needs to be converted.

sudo alien abc.rpm



vim uses

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

In command mode:

:q quit

:q! Force quit

:wq save and quit

:set number show line number

:set nonumber hide line number

/apache find apache in documentation press n to jump to next, shift+n to previous

yyp copy The line where the cursor is located, and paste

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



user and user group management

/etc/passwd store user account

/ etc/group store group account

/etc/shadow store user account password

/etc/gshadow store the password of the user group account

useradd user name

userdel user name

adduser user name

groupadd group name

groupdel group name

passwd root set password for root

su root

su - root

/etc/profile system environment variable

bash_profile user environment variable.bashrc

user Environment variable

su user switch user, load configuration file. bashrc

su - user switch user, load configuration file /etc/profile, load bash_profile

Change file user and user group

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

For example: also take jdk-7u21-linux-i586.tar.gz as an example. It belongs to the user hadoop, and the group hadoop

wants to switch the user and group to which this file belongs. Commands can be used.

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



file permissions management

three basic permissions

R read The value is expressed as 4

W write value is represented as 2

X executable value is represented as 1

As shown in the figure, the permissions of the jdk-7u21-linux-i586.tar.gz file are -rw-rw-r--

-rw-rw-r-- in total Ten characters, divided into four paragraphs.

The first character "-" indicates a normal file; there may also be a "l" link in this position; "d" indicates a directory

The second , third, and fourth characters "rw-" indicate the permissions of the current user. Therefore, the numerical value is expressed as 4+2=6

The fifth, sixth, and seventh characters "rw-" indicate the permissions of the current group. Therefore, the numerical value is expressed as 4+2=6

The eighth and ninetieth characters "r--" represent other user permissions. So the value is expressed as 2

, so the permission to operate this file is expressed as 662.

Change the permission

sudo chmod [u belongs to the user g belongs to the group o other users a all users] [+ increase permission - decrease permission] [r w x] directory name

For example : There is a file filename, the permission is "-rw-r----x", change the permission value to "-rwxrw-rx", and the value is 765

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

above Example can be expressed as a value

sudo chmod 765 filename

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326350738&siteId=291194637