MU-class network: Linux talent nurturance program _2_ Linux common Commands __linux

Source: Internet
Author: User
Tags bz2 create directory pack file permissions
mu network: Linux talent Formation program <2> Linux common Commands Linux Common Commands 1. Command basic format

linyk3@thinkpad:~$ linyk3: Login user name ThinkPad: Host name ~: Current Location $: normal User, #: root user

command [options] [parameters]
Simplify option-a full option--all ls [options] [parameters] -A view all files, including hidden files-L display file details-D View Directory Properties-H humanized display file size-i display inode 2. File processing Commands 2.1 Directory processing Commands

Create directory: mkdir:mkdir-p [directory name]
Make directories
-p recursively Create a directory

Open Directory: CD
Relative path, absolute path

View current directory
Pwd

Delete directory: rmdir remove empty directories Delete empty directory

Delete files or directories: RM [-RF] [files or directories]
Rm-r: Delete Directory
Rm-f: Force Delete 2.2 file Processing command

Copy command: CP [Options] [Original file or directory] [target directory] Copy
-R Replication Directory
-P Joint File property copy
-D If the source file is a linked file, copy the link property
-A equivalent to-PDR

Cut or Rename command MV [original file or directory] [target directory] Move
When manipulating directories, do not add-r

The role of the Common directory:/root directory/bin command to maintain the directory, ordinary users can access the/boot boot directory, start related files/dev device file save directory/etc configuration file save directory/home Ordinary user's home directory/lib system library save directory/mnt System mount directory /media hangs in directory/root Superuser's home directory/tmp temporary directory/sbin Command Save directory (Superuser can use)/proc Direct write memory, can not directly operate, is the memory overload point/sys can not directly operate, is the memory overload point

/usr/usr/bin/system Command Ordinary User/usr/sbin/System command superuser/var System related document contents 2.3 Link Commands

ln-s [Original file] [target file] Link
To generate a linked file
-S to create soft links

Hard link features have the same I node and storage block blocks, which can be seen as the same file can be identified through the I node cannot be used across partitions for directory use

Soft link features similar to Windows shortcut soft links have their own I nodes and block blocks, but the data block to save only the original file name and I node number, and no actual file data lrwxrwxrwx L: Soft link Soft link file permissions are modified for rwxrwxrwx arbitrary file , the other is changed to delete the original file, soft link can not use 3. File Search command 3.1 File Search command locate

locate [filename]

Search the file name in the background database and search faster

/var/lib/mlocate

Database for locate command search

UpdateDB

The Mlocate database is updated daily and the commands are manually updated. /ETC/UPDATEDB.CONF filter rules when configuring files

Disadvantages:
Only search file name, find powerful but consumes 3.2 command search command Whereis and which

Whereis command name
The path where the search command is located and the location of the Help document
-B Find only executable files
-M find Help files only

which
Search command location, if alias, also displayed

Shell built-in commands cannot be found with which and wehreis, such as CDs $PATH Environment Variables

Defines the path to the system search command 3.3 file Search command Find

Find [Search scope] [search conditions]
Search for files

Find/-name Install.log
Attention
-Avoid a wide range of searches and will consume system resources very much
-Find is to search the system for eligible file names, and if you use wildcard characters, it will be exactly the same

    -*  match any character
    -. Match any one character
    -[]   match any one of the characters in the brackets

Find/root-iname install is case-insensitive
Find/root-user root to search by file owner
Find/root-nouser Find files without owners: kernel-generated files and foreign files may not have owners

Find/var/log-mtime +10 Find Files modified 10 days ago-10 10 days 10 10 days ago the day of the modified file +10 10 days ago Atime file access time CTime file attributes change time mtime modify file contents

Find. -size 25k Find File size is 25KB file -25k less than 25kb m 25k equals 25kb m +25k greater than 25kb m

Find/etc-size +20k-a-size-50m Check for files larger than 20KB and less than 50M

Find/etc-size +20k-a-size-50m-exec ls-lh {} \;
Check for files larger than 20KB and less than 50M, and show details-exec/-ok command {}\ is the action performed on search results-A and logic with-o or logical OR

Find. -inum 262422 Find I node 262422 of the file 3.4 string search command grep

grep [option] string file name
Matching strings in a file-I ignores case-V excludes the specified string, and vice versa the difference between the Find command and the grep command is found: Search the system for eligible file names, and if a match is required, wildcard matches are 3.5, and wildcard characters are exactly matched. grep: Searches for strings that match criteria in a file, matches with regular expressions if a match is needed, and a regular expression that contains a match. 4. Help command 4.1 mans Command Manul

Man's Level:
1 executable program or shell command
2 system calls (functions provided by the kernel)
3 Library calls (functions in the library)
4 special files (usually located in/dev)
5 file formats and specifications, such as/etc/passwd
6 games
7 miscellaneous (including macro packages and specifications, such as man (7), Groff (7))
8 System Management commands (usually only for root users)
9 kernel routines [non-standard]

Man-f command, which is equivalent to the level of Help for Whereis view commands

For example
man-f passwd man
5 passwd man
1 passwd
whereis passwd

The Man-k command corresponds to the apropos command, viewing all of the help related to the command 4.2 Other command –help//Get command options help the shell internal command//get help from the shell internal command. You can use the Whereis command to determine whether the command is a shell internal command or an externally installed command. Shell built-in commands cannot be found with which and wehreis, such as CDs 5. Compression and Decompression commands 5.1. zip

Compressed command Zip Compressed file name source file//Compressed file Zip-r compressed filename source directory//Compressed directory

Extract command Unzip compressed file name//Compressed Files 5.2. gz gzip source files//compressed files for. GZ, source files will disappear gzip-c source files > Compressed files//compressed to. gz format, source files keep Gzip-r directory Compress all of the subfolders under the directory, but you cannot compress the directory 5.3. bz2 bzip2 source files//compression to. bz2 format, do not keep source files bzip2 source files//compressed to keep source files
BZIP2 command cannot compress directory 5.4 tar pack command

TAR-CVF packaged file name source file
Option C: Package V: Display process

F: Specify the file name after packing

EG:TAR-CVF Linyk3.tar linyk3 5.5 Solution Pack Command

TAR-XVF Packaged file name
Options

X Solution Package

EG:TAR-XVF Linyk3.tar 5.6. tar.gz

The. tar.gz format is packaged in. tar format and then compressed to. gz format.

TAR-ZCVF compression package name. tar.gz source file//compression to. tar.gz format
TAR-ZXVF compressed package name. tar.gz//uncompressed. tar.gz format 5.5. tar.bz2

The. tar.bz2 format is packaged as. tar format and then compressed to. bz2 format
TAR-JCVF compression package name. tar.bz2 source file//compression to. tat.bz2 format
TAR-JXVF compressed package name. TAR.BZ2//uncompressed. tar.bz2 format 6. Shutdown and restart command 6.1 shutdown Command

shutdown [option] Time
Option C: Cancel previous shutdown command h: Shutdown r: Restart other shutdown commands halt poweroff init 0

All three commands can be shut down, but not secure. Shutdown is more secure and will be saved. other reboot command reboot init 6 system Run level init total 7 levels 0 shutdown 1 Single user 2 not full multiuser, no NFS Services 3 full multiuser 4 Unassigned 5 graphical interface

6 reboot

RunLevel can view current run level exit login, log off

Logout
Develop good habits without directly crossing the CRT 7. Other common commands 7.1 mount command

Mount point-sub-letter 1. Query and Auto Mount

$ mount
Querying for devices that are already mounted in the system
$ mount-a
Automatically mount 2 according to the contents of the configuration file/etc/fstab . Mount command Format

$ mount [-t file system] [-o Special Options] Device filename mount point-t file system: Join file system type to specify mount type, can ext3,ext4,ios9660 (CD) and other file System-O Special options: You can specify additional options for mounts

$ mount-o Remount,noexec/home
Re-mount the/home partition and use noexec permissions (do not run Execute permissions, even the root directory) 3. Mount Disc mkdir/mnt/cdrom/build mount point mount-t iso9660/dev/src0/mnt/cdrom Mount CD 4. Uninstall Command

Umount device file name or mount point
Be sure to uninstall 5 when you are done with it . Mount U disk

Fdisk-l View Partitions
Mount-t Vfat/dev/sdb1/mnt/usb
Linux defaults to 7.2 user logins that do not support the NTFS file system view 1. View user Information

w [user name]
who 2. View user information for the current login and past logins, including restart time

Last
The default read file is/var/log/wtmp 3. View all users in the system for last logon information

Lastlog
The default read is/var/log/lastlog

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.