User Tools

Site Tools

Advertisements: AliExpress Hide Your IP Microsoft Products



Creating tar archive

tar cf <file.tar> <files>

Extracting tar archive

tar xf <file.tar>

Creating a tar with gzip compression

tar czf <file.tar.gz> <files>

Extracting tar Using Gzip

tar xzf <file.tar.gz>

Creating a tar with bzip2 compression

tar cjf <file.tar.bz2>

Extracting a tar using bzip2

tar xjf <file.tar.bz2>

Compressing file and renaming it to file.gz

gzip <file>

Decompressing file.gz back to file

gzip -d <file.gz>

Compressing files with zip

zip <> <input files>

Compressing directories/files and its content with zip

zip -r <> <inputdirs and files>

Decompressing zip archive

unzip <>

Decompressing zip archive to directory

unzip <> -d <outputdir>


Directory listing


Listing directory with hidden files and additional info, like owner or human readable file sizes

ls -alh

Current working directory


Changing directory to dir

cd <dir>

Changing directory to home


Removing file

rm <file>

Removing directories

rm -r <dir1> <dir2>

Removing files by forcing (ignores nonexistent files/dirs)

rm -fr <files dirs> # you can use -i to prompt before removal and -v for what is being removed

Copy file1 to file2

cp <file1> <file2>

Copy dir1 to dir2

cp -r <dir1> <dir2>

Print file content

cat <filepath>

Print last 20 lines of file content

tail -20 <filepath>

output the contents of file as it grows, starting with the last 10 lines

tail -f <filepath>

output the contents of a file or standard input line by line but in reverse order, printing last line first

tac [OPTIONS]... [FILE]...

APT - Debian Package Upgrade/Installation

Upgrade from registered repositories

apt-get update
apt-get upgrade


aptitude update
aptitude upgrade

Install local package

dpkg -i <deb file path>

List packages in system

dpkg -l | grep ^i


dpkg --get-selections | grep -E "\s+install$"

Show package's info

aptitude show <package name>


apt-cache show <package name>

Show dependency of a package

apt-cache depends <package name>

Show reverse dependency of a package

apt-cache rdepends <package name>

Search a file to find which package belongs to

dpkg -S <any_string>

Bash Keyboard Shortcuts

Ctrl+C – Interrupt/Kill whatever you are running

Ctrl+Z – Suspen whatever you are running, resume with fg in the foreground or bg in the background

Ctrl+D – log out of current session, similar to exit

Ctrl+W – erases one word from left in the current line

Ctrl+U – cuts from cursor to left

Ctrl+K – cuts from cursor to right

Ctrl+Y – Paste the last thing to be cut

Ctrl+R – bring up history search and type to find command includes the text you entered (if you press Ctrl+R again, you can see other command alternative)

!! - repeats the last command

exit – log out of current session

linux/cheat_sheet.txt · Last modified: 2016/11/03 06:24 by ozan