Common linux commands and common linux commands

Source: Internet
Author: User
Tags create directory

Common linux commands and common linux commands

Common commands

Ls display file or directory

-L list file DETAILS l (list)

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

Mkdir create directory

-P: Creates a directory. If no parent directory exists, p (parent) is created)

Cd switch directory

Touch creates an empty file

Echo creates a file with content.

Cat View File Content

Cp copy

Move or rename music videos

Rm delete file

-R recursively deletes sub-directories and files.

-F force Delete

Find searches for a file in the file system

Wc counts the number of rows, words, and characters in the text

Grep searches for a string in a text file.

Rmdir Delete empty directory

Tree structure display directory, you need to install the tree package

Pwd displays the current directory

Ln create link file

More and less display text file content by PAGE

Head and tail show file header and tail content

Ctrl + alt + F1 command line full screen mode

 

System Management commands

Stat displays the details of the specified file, which is more detailed than ls.

Who displays online login users

Whoami displays the current user

Hostname display Host Name

Uname: displays system information

Top dynamically displays the process information that currently consumes the most resources

Ps displays the Instantaneous Process status ps-aux

Du: view the directory size. du-h/home displays the directory information in units.

Df view disk size df-h Displays disk information in units

Ifconfig

Ping test network connection

Netstat displays network status information

The man Command won't be used anymore. Look for a man like man ls.

Clear Screen

Alias rename the command, for example, alias showmeit = "ps-aux", and unaliax showmeit

Kill to kill a process. You can view the process id with the ps or top command, and then kill the process with the kill command.

 

Compress related commands

Gzip:

Bzip2:

Tar: Package and Compression

-C. archive file

-X compressed file

-Z gzip compressed file

-J bzip2: compressed file

-V shows the compression or decompression process v (view)

-F indicates the file name.

Example:

Tar-cvf/home/abc.tar/home/abc Package only, not compressed

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

Package tar-jcvf/home/abc.tar.bz2/home/abc and compress it with bzip2

If you want to decompress the package, replace "c" in the tar-cvf/tar-zcvf/tar-jcvf command with "x.

 

Shut down/restart the machine

Shutdown

-R: shutdown and restart

-H Shutdown without restarting

Now shut down immediately

Halt Shutdown

Reboot restart

 

Linux Pipelines

Use the standard output of one command as the standard input of another command. That is, several commands are combined for use, and the result of the last command is exclusive to the previous one.

For example, grep-r "close"/home/* | more searches for all files in the home directory, including close files, and outputs them by page.

 

Linux software package management

Dpkg(Debian Package) management tool. The Package name is suffixed with. deb. This method is suitable when the system cannot be connected to the Internet.

For example, to install the installation package of the tree Command, first upload tree. deb to the Linux system. Run the following command to install the SDK.

Sudo dpkg-I tree_1.5.3-1_i386.deb Installation Software

Sudo dpkg-r tree uninstall software

 

Note: There are multiple methods to upload tree. deb to Linux. VMwareTool, using the mounting method; using the winSCP tool;

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

Tree is used as an example.

Sudo apt-get install tree installation tree

Sudo apt-get remove tree uninstall tree

Sudo apt-get update Software

Sudo apt-get upgrade

 

Set.RpmConvert the file.DebFile

. Rpm is the software format used by RedHat. It cannot be used directly in Ubuntu, so you need to convert it.

Sudo alien abc. rpm

 

Use vim

Vim mode: Command mode, insert mode, and edit mode. Use ESC or I or: to switch the mode.

In command mode:

: Q exit

: Q! Force exit

: Wq save and exit

: Set number: displays the row number.

: Set nonumber hide row number

/Apache finds in the document that apache jumps to the next one by pressing n, shift + n

Copy and paste the row where the cursor is located.

H (move one character to the left), j (next line), k (last line), l (move one character to the right →)

 

User and User Group Management

/Etc/passwd storage User Account

/Etc/group storage group account

/Etc/shadow stores the password of the user account

/Etc/gshadow: password used to store user group accounts

Useradd Username

Userdel Username

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 variables

. Bashrc user environment variable

Su user switches users and loads the configuration file. bashrc

Su-user: Switch the user, load the configuration file/etc/profile, and load the bash_profile

Users and user groups who change files

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

For example, jdk-7u21-linux-i586.tar.gz is used as an example. Belong to user hadoop, group hadoop

To switch the user and group to which the file belongs. You can use commands.

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

 

File Permission Management

Three basic Permissions

The R read value is 4.

W write value is expressed as 2

X executable value is 1

The permission for the jdk-7u21-linux-i586.tar.gz file is-rw-r --

-Rw-r -- a total of 10 characters, which are divided into four segments.

The first character "-" indicates a common file. This location may contain "l" links, and "d" indicates a directory.

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

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

The 80 or 90 character "r --" indicates other user permissions. So the value is 2.

Therefore, the permission to operate this file is expressed as 662 in numerical values.

Change permissions

Sudo chmod [u user g owner group o other user a all users] [+ add permissions-Reduce permissions] [r w x] Directory Name

For example, if you have a file filename with the "-rw-r ---- x" permission, change the permission value to "-rwxrw-r-x", and the value is 765.

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

The preceding example can be represented by numerical values.

Sudo chmod 765 filename

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.