[go: up one dir, main page]

0% found this document useful (0 votes)
121 views2 pages

SS Bash - Linux CL Cheatsheet

This document provides a cheat sheet of common Linux commands and their usage. It summarizes commands for system information, file manipulation, process management, file permissions, input/output redirection, and searching files. Shortcuts are also listed for Bash, Nano text editor, and the Screen terminal multiplexer.

Uploaded by

Jackreece Ejini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views2 pages

SS Bash - Linux CL Cheatsheet

This document provides a cheat sheet of common Linux commands and their usage. It summarizes commands for system information, file manipulation, process management, file permissions, input/output redirection, and searching files. Shortcuts are also listed for Bash, Nano text editor, and the Screen terminal multiplexer.

Uploaded by

Jackreece Ejini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Linux Command Line Cheat Sheet

Bash Commands Bash Variables (cont) Command Lists

uname -a Show system and export NAME=value Set $NAME to value cmd1 ; cmd2
kernel | Run cmd1 then cmd2

$PATH Executable search path


head -n1 /etc/issue Show distribution cmd1 && cmd2
| Run cmd2 if cmd1 is successful
$HOME Home directory
mount Show mounted filesystems
cmd1 || cmd2
$SHELL Current shell | Run cmd2 if cmd1 is not successful
date Show system date

cmd &
uptime Show uptime | Run cmd in a subshell
IO Redirection
whoami Show your username
cmd < file Directory Operations
man command Show manual for command | Input of cmd from file
pwd Show current directory
cmd1 <(cmd2)
| Output of cmd2 as file input to cmd1
mkdir dir Make directory dir
Bash Shortcuts
cmd > file
cd dir Change directory to dir
CTRL-c Stop current command | Standard output (stdout) of cmd to file

cd .. Go up a directory
cmd > /dev/null
CTRL-z Sleep program
| Discard stdout of cmd
ls List files

CTRL-a Go to start of line cmd >> file


| Append stdout to file
CTRL-e Go to end of line ls Options
cmd 2> file
| Error output (stderr) of cmd to file -a Show all (including hidden)
CTRL-u Cut from start of line

cmd 1>&2 -R Recursive list


CTRL-k Cut to end of line | stdout to same place as stderr
-r Reverse order
CTRL-r Search history cmd 2>&1
| stderr to same place as stdout -t Sort by last modified
!! Repeat last command
cmd &> file -S Sort by file size
| Every output of cmd to file
!abc Run last command starting with
abc
-l Long listing format
cmd refers to a command.
!abc:p Print last command starting -1 One file per line
with abc

Pipes -m Comma-separated output


!$ Last argument of previous
command
cmd1 | cmd2
-Q Quoted output
| stdout of cmd1 to cmd2
ALT-. Last argument of previous
command
cmd1 |& cmd2 Search Files
!* All arguments of previous | stderr of cmd1 to cmd2
command grep pattern files Search for pattern in files

^abc^123 Run previous grep -i Case insensitive search


command,replacing abc with File Permissions
123
grep -r Recursive search
chmod 775 file
| Change mode of file to 775
grep -v Inverted search
Bash Variables
chmod -R 600 folder
| Recursively chmod folder to 600 grep -o Show matched part of file
env Show environment variables
only

chown user:group file find /dir/ -name name* Find files starting with
echo $NAME Output value of $NAME variable
| Change file owner to user and group to group name in dir
Linux Command Line Cheat Sheet
Search Files (cont) Process Management Screen Shortcuts (cont)

find /dir/ -user name Find files owned by name in ps Show snapshot of processes screen
dir | Start a screen session
top Show real time processes
find /dir/ -mmin num Find files modified less than
num minutes ago in dir screen -r
kill pid Kill process with id pid
| Resume a screen session.

whereis command Find binary / source / pkill name Kill process with name name
manual for command
screen -list
killall name Kill all processes with names | Show your current screen sessions.
locate file Find file (quick search of beginning name
system index)
CTRL-A
Nano Shortcuts | Activate commands for screen.

File Operations
Files
CTRL-A c
touch file1 | Create a new instance of terminal.
| Create file1 Ctrl-R Read file

cat file1 file2 Ctrl-O Save file CTRL-A n


| Concatenate files and output | Go to the next instance of terminal.
Ctrl-X Close file

less file1
Cut and Paste CTRL-A p
| View and paginate file1
| Go to the previous instance of terminal.
ALT-A Start marking text
file file1
| Get type of file1 CTRL-A "
CTRL-K Cut marked text or line | Show current instances of terminals.
cp file1 file2
| Copy file1 to file2 CTRL-U Paste text
CTRL-A A
Navigate File | Rename the current instance.
mv file1 file2
| Move file1 to file2
ALT-/ End of file
More screen info at:
rm file1 http://www.gnu.org/software/screen/
| Delete file1 CTRL-A Beginning of line

CTRL-E End of line


head file1
| Show first 10 lines of file1 File Permission Numbers
CTRL-C Show line number
First digit is owner permission, second is
tail file1
CTRL-_ Go to line number group and third is everyone.
| Show last 10 lines of file1

Search File Calculate permission digits by adding


tail -F file1
| Output last lines of file1 as it changes numbers below.
CTRL-W Find

4 read (r)
ALT-W Find next
Watch a Command
CTRL-\ Search and replace 2 write (w)
watch -n 5 'ntpq -p'
| Issue the 'ntpq -p' command every 5
| seconds and display output More nano info at: 1 execute (x)
http://www.nano-editor.org/docs.php

Linux Command Line Cheat Sheet by DaveChild is licensed under CC 2.0

You might also like