Linux Command Line Cheat Sheet

by Dave Child (DaveChild) via

Bash Commandsuname -a

Show system and kernelhead -n1 /etc/issueShow distribution

mountShow mounted filesystemsdateShow system dateuptimeShow uptimewhoamiShow your usernameman commandShow manual for command

Bash ShortcutsCTRL-cStop current commandCTRL-zSleep programCTRL-aGo to start of lineCTRL-eGo to end of lineCTRL-uCut from start of lineCTRL-kCut to end of lineCTRL-rSearch history!!Repeat last command

!abcRun last command starting with abc!abc:pPrint last command starting with abc!$Last argument of previous http://www.51wendang.comst argument of previous command!*All arguments of previous command^abc^Run previous command, replacing abc123

with 123

Bash Variablesenv

Show environment variablesecho $NAME

Output value of $NAMEvariable

export NAME=vSet $NAME to value

alue$PATHExecutable search path$HOMEHome directory$SHELLCurrent shell

IO Redirectioncmd < file

Input of cmd from filecmd1 <(cmd2)

Output of cmd2 as file input to cmd1cmd > file

Standard output (stdout) of cmd to filecmd > /dev/null

Discard stdout of cmdcmd >> file

Append stdout to filecmd 2> file

Error output (stderr) of cmd to filecmd 1>&2

stdout to same place as stderrcmd 2>&1

stderr to same place as stdoutcmd &> file

Every output of cmd to file

Directory OperationspwdShow current directorymkdir dirMake directory dircd dirChange directory to dircd ..Go up a directoryls

List files

ls Options-aShow all (including hidden)-RRecursive list-rReverse order-tSort by last modified-SSort by file size-lLong listing format-1One file per line

-mComma-separated output-Q

Quoted output

Search Filesgrep patternSearch for pattern in files

filesgrep -iCase insensitive searchgrep -rRecursive searchgrep -vInverted search

grep -oShow matched part of file onlyfind /dir/ -name

Find files starting with name in dirname*find /dir/ -userFind files owned by name in dirname

find /dir/ -mminFind files modifed less than numnumminutes ago in dir

whereisFind binary / source / manual forcommandcommand

locate file

Find file (quick search of systemindex)

File Operationstouch file1Create file1cat file1 file2

Concatenate files and outputless file1

View and paginate file1file file1

Get type of file1cp file1 file2Copy file1 to file2mv file1 file2Move file1 to file2rm file1Delete file1head file1

Show first 10 lines of file1tail file1

Show last 10 lines of file1

Nano ShortcutsFilesCtrl-RRead fileCtrl-OSave fileCtrl-X

Close file

Cut and PasteALT-AStart marking textCTRL-KCut marked text or lineCTRL-UPaste textNavigate FileALT-/End of fileCTRL-ABeginning of lineCTRL-EEnd of lineCTRL-CShow line numberCTRL-_Go to line numberSearch FileCTRL-WFindALT-WFind next


Search and replaceMore nano info at: Shortcutsscreen

Start a screen session.screen -r

Resume a screen session.screen -list

Show your current screen sessions.CTRL-A

Activate commands for screen.CTRL-A c

Create a new instance of terminal.CTRL-A n

Go to the next instance of terminal.CTRL-A p

Go to the previous instance of terminal.CTRL-A "

Show current instances of terminals.CTRL-A A

Rename the current instance.More screen info at:

File Permissionschmod 775 file

Change mode of file to 775chmod -R 600 folder

Recursively chmod folder to 600chown user:group file

Change file owner to user and group to group

File Permission Numbers

The first digit is the owner permission, the second thegroup and the third for everyone.

Word文档免费下载Word文档免费下载:linux命令帮助手册 (共2页,当前第1页)


  • C语言函数
  • Linux系统命令及其使用详解
  • Excel使用技巧大全(超
  • 研究分析
  • linux命令
  • 战略研究