Notes on basic linux commands

Source: Internet
Author: User

Notes on basic linux commands
0. ls-lh
Display Properties of files in the current directory in a user-friendly manner

1. Link:
Hard Link (itself is the file pointer, equivalent to the original file pointer)
Ln filename1 filename2
Soft link (itself a pointer, creating a pointer to the original file)
Ln-s absolute path filename2

2. Search:
File Search
Locate (fast, but only search by file name)
Search/var/lib/mlocate in the database and update it once a day.
Force update updatedb or locate
Configuration file/etc/updatedb. conf

Find (strong, slow, difficult)
Find path-name filename
(-Iname is case insensitive
-User search by owner
-Nouser: Search for files without owners,
Junk files, kernel files, or external files
)
The search content exactly matches. Otherwise, the wildcard *? []
Eg: find/root-name "AB [cd]"

Find/var/log/-mtine + 10
Search for files modified 10 days ago
(-Files modified within 10 days
Files modified on the 10th day
+ Files modified 10 days ago

-Atime File Access time
-Ctime: change file attributes
-Mtime: Modify file content
-Size: the file size is k MB.
-Inum I node Query file name
)

Find/etc-size + 20 k-a-size-50 k
-A logic and
-O logic or

Find cmd1-exec cmd2 {}\;
-Exec cmd {}\; fixed combination
The processing result of cmd1 is processed by cmd2.


Command search
Whereis command name
Only system commands can be checked
Which command name
Display command alias


String search
Grep [options] string filename
-I case-insensitive
-V: exclude the specified Character Set

3. Help
Man-f cmd
Equivalent to whatis cmd

Apropos cmd
Find the cmd help information

Cmd -- help

Shell Internal Command help
Help cmd
Use whereis cmd to determine whether cmd is an internal command

Info cmd
Great help

4. Compression
Zip zipname srcname
-R compression directory
Unzip zipname filename
Unzipping without parameters, keep the source file

Gzip source file (the source file disappears)
-R compression directory (files under the Directory)
-D. Decompress gunzip.

Bzip2 source file (directory cannot be compressed)
-K keep source files
-D. Decompress bunzip2.

Tar-cvf package file name source file
(-C Packaging
-X unpack
-V process
-F: Specify the package file name.
)
Tar-zcvf compressed file name source file
(-Z. gz
-J. bz2
)
Tar-zxvf compressed package-C decompression location
-C: Specifies the decompression location
Tar-ztvf compressed package
-T check the files in the compressed package.

5. Shutdown
Shutdown [options] time
-R restart
-H shutdown halt poweroff init 0
-C. Cancel the previous shutdown command.

Init 6 (?? Try to fix ??)

Logout (exit the Remote Management Terminal)

6. Mount
Mount to view Mounted Directories
Mount-a automatically mounts the content in/etc/fstab.

Mount [-t file system] [-o Special option] device file name mount point
-T ext4 iso9660

Mount-o remount, noexec/home/
Re-mount/home cannot execute executable files
Mount-o remount, exec/home/
Remount/home

Attach a cd
Mkdir/mnt/cdrom
Mount-t iso9660/dev/sr0/mnt/cdrom/
Uninstall
Umount device file name or mount point

Mount a USB flash drive
Fdisk-l
Mount-t vfat/dev/sdb1/mnt/usb/

-T option can be omitted in general

7. View logon user information
W
Who
Last read/var/log/wtmp
Lastlog/var/log/lastlog

8. shell
/Etc/shells contains the shell that can be used in Linux
Enter the shell name to enter the specified shell

Script Execution
Chmod 755 filename. sh
./Filename. sh

Bash filename. sh

Alias
Alias
Alias ls = 'ls -- color = never'
Alias rm = 'rm-rf'

Unalias alias

~ /. Bashrc alias environment variable configuration file

Shortcut Key
Ctrl + c terminate
Ctrl + l clear screen
Ctrl + u Delete All characters before the cursor
Ctrl + a move the cursor to the beginning of the line
Ctrl + e move the cursor to the end of the row
Ctrl + z move the command to the background
Ctrl + r search in History commands

History commands
History [options] [file]
-C clear History commands
-W: Save History commands to files ~ /. Bash_history
Environment variable configuration file/etc/profile
! N: Execute the nth historical command
!! Repeat the previous command
! Run the last command starting with a string repeatedly.

Output redirection
Command> File
Command> File
Error command 2> File
Error command 2> File

Command> file 2> & 1
Command> file 2> & 1
Command &> File
Command &> File
Alias fuck = 'ls &>/dev/null'
Command> file 1 2> file 2

Input redirection
Wc

Pipeline operator
; Command 1; command 2 separator, no effect
& Command 1 & command 2 command 1 can be executed successfully before command 2 can be executed
| Command 1 | command 2: command 1: Execution 2: Not execution; otherwise, 2: Execution

Date; locate "l"; date
Ls & echo yes | echo no, correct yes, error no

Command 1 | command 2 command 1 result to command 2
Netstat-an | grep ESTABLISHED | wc-l

Wildcard
? * [] [-] [^]

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.