Linux common commands and important file directories

Source: Internet
Author: User

Important File directories (System-assigned directories);

Root: The file that holds the root user

HOME: Files for ordinary users (new users)

BIN: Directory CD to store common commands switch directory ls dir

SBIN: Store commands that you want to be able to use with certain permissions

MNT: Default mount directory for CD-ROM and floppy drive

ETC: Store configuration-related files, Mysql,tomcat,

USR: File Default installed folder, program files like XP

VAR: Store frequently changing data, such as Web pages, Apache

Boot: Store boot-related files

Linux Common commands

Go to Desktop command: STARTX

Shutdown: shutdown-h Now

Restart: Shutdown-r now/reboot

Try to log in as little as possible, using the normal user, "Su-" to switch

Unregister logout shortcut keys Ctrl+d

Detailed list: ls-l (more info) ls-al (Show hidden files, details)

Shows which directory is currently in: PWD

Add User Useradd Useradd xiaoming

Set Password passwd passwd xiaoming system will prompt for a new password, two times input

Prompt # indicates that the root user $ represents a normal user

Delete User Userdel Userdel xiaoming just remove user name or Userdel-r xiaoming Delete user and user home directory

mkdir Building a Directory

RmDir Delete Empty directory If there is content?

TAB command complete the same, you can press two times

Touch to create an empty file

CP Cp-rdir1 DIR2 Recursive replication

More page display can not flip crtl+pageup space backward;

Less pagination shows that you can flip forward

grep queries the text for grep-n (show rows) "keyword" file name

Find search files and directories

Find/-name Aaa.java/Represents the root directory,

find/root/-name Aaa.java Lock Range

Data redirection Save the action flow to another place

Grep-n (number of rows) "keyword" file name >kkk.bak > output to

Ls-l > A.txt

Ls-al

>> Append Write

> Overwrite Write

How to view an existing group: Vi/etc/group Cat/etc/group

View all user information: CAT/ETC/PASSWD

Create a user and add to the specified group

USERADD-G Group name User name

Taking-rw-r--r--as an example

The first "-" represents a file, and if it is a directory, it is denoted by "D".

Second--Four: Represents the permissions that all groups of files have on this file

R readable number means 4 W writable number means 2 x executable digit 1

Maximum file permissions 666, directory maximum permissions 777

Five--Seven: Represents the permissions that a group of files have on this file

Eighth--10: Represents the permissions that other groups have on this file

Chown User name File name modify file owner

CHGRP Group name File name modify file all groups

History 5 Recently used 5 commands

!5: This description executes a command with a history number of 5

!ls: This description executes the last command that starts with "LS"

Stat View the owner of a file or directory
Example: Stat cmd.txt See information about Cmd.txt file
Example: stat-c%u cmd.txt get the owner of Cmd.txt under the current directory
Example: Stat-c%u/home/game/test get owner of/home/game/test directory
LN creates a link for the file in a different location
Example: Ln-sf/home/appsvr appsvrlink//Create a soft link in the current directory named Appsvrlink (link to/home/appsvr)
Example: Ln-f/home/expsvr expsvrlink//Create a hard link in the current directory called Expsvrlink (link to/home/expsvr)
--------------------------------
-F: When creating a link, delete the link with the same name first
-I: When deleting, ask first
-S: Soft junction (symbolic Link)
There are two kinds of links, one is called hard link, the other is called soft link (symbolic link, symbolic links).
When a hard link is established, the linked file and the linked file must be in the same partition, and a hard link to the directory cannot be established.
A hard link will generate a file of the same size as the source file at the selected location, and a soft link will only generate a mirror image of the file at the selected location and will not consume disk space.

Soft links can span partitions and can point to directories. Files are kept in sync, whether they are soft links or hard links.

top   Dynamic display system current process and other state information
--------------------------------------------
H: Print out Help information     Spaces: Refresh now    k: Terminate a process    Q: Exit top
Free view memory usage
Example: Free      //view current in Storage usage status, unit byte
Example: Free-m  //View current memory usage, units MB, parameters can also be-g,-K, etc.
PS   Process View Command
Example: Ps-ux   View Current user run process information
Example: Ps-aux//View the processes that are currently running for all users
Example: ps-elf//Another common instruction to view all users running Processes
Example: PS axwef  //list processes and sub-processes in tree form
Example: PS aux | sort- NK +4 | Tail   List The first 10 most memory-consuming processes
Kill   End a specified process
Example: kill-9 352     Ending a process with PID 352
Example: Killall gamesvr// Terminates all processes named Gamesvr
Example: killall-9 gamesvr//force termination of all processes named Gamesvr
Pmap View memory image Information
Example: Pmap 13455    // View memory image information with process ID 13455 (with memory usage, loaded so, etc.)

Netstat
Example: NETSTAT–TLNP list the port number that the native process listens on
Example: Netstat-anop can display a process that listens on a port number
Example: Netstat-anop | grep 10.6.221.70 Current host connection to 10.6.221.70 information
Example: Netstat-anop | grep 9005 information for the current host connecting to Port 9005


Linux common commands and important file directories

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.