Linux Command Line Cheatsheet

ADVERTISEMENT

Linux Command Line
Make Tech Easier
Cheatsheet
File Commands
System Commands
ls - List the content of the current directory
uname -a - Show system and kernel
ls -R - List the subdirectories recursively
head -n1 /etc/issue - Show distribution
ls -a - List all the content, including hidden files
mount - Show mounted filesystems
ls -l - List the content and its information
date - Show system date
pwd - Output the current directory that you are in
uptime - Show system uptime
cd folder1 – Change the working directory to folder1
whoami - Show your username
cd - Return to the $Home directory
w - Display who is online
cd .. - Go up a directory
man command - Show manual for command
cd - - Return to the previous directory
mount -o loop cdrom.iso /mnt/dir - Mount cdrom.iso at
/mnt/dir
cp source destination – Copy source to destination
cp -r source destination – Copy a folder recursively from
cat /proc/partitions - Show all partitions registered on the
source to destination
system
mv source destination - Move (or rename) a file from source to
grep MemTotal /proc/meminfo - Show RAM total seen by the
destination
system
rm file1 - Remove file1
grep "model name" /proc/cpuinfo - Show CPU(s) info
rm -f file1 - Remove file1 without prompt
lspci -tv - Show PCI info
rm -r folder - Remove a folder and its content recursively
lsusb -tv - Show USB info
!! - Repeat the last command
mkdir foldername – Create a new folder foldername
rmdir foldername – Remove an empty folder
exit – Log out of current session
file file1 – Show the file type of file1
cat file1 file2 – Concatenate file1 to file 2
File Searching Commands
cat > file1 – Concatenate standard input to file1
grep pattern files - Search for pattern in files
less file1 - View and paginate file1
grep -i - Case insensitive search
head file1 - Show first 10 lines of file1
grep -r - Recursive search
tail file1 - Show last 10 lines of file1
grep -v - Inverted search
chmod 777 file - Change file permission of file to 777
grep -o - Show matched part of file only
locate file1 - Find file1
chown user:group file - Change ownership of file to user and
group group
whereis command - Find binary/source /manual for command
which app – Locate a command for the app
ln -s source destination – Create a symbolic link from source to
destination
look string file1 - Display any lines in file1 which contain string
as a prefix.
File Encryption and Compression
find /dir/ -user name - Find files owned by name in dir
gpg -c file - Encrypt file
find /dir/ -mmin num - Find files modifed less than num
minutes ago in dir
gpg file.gpg - Decrypt file.gpg
find /dir/ -name name* - Find files starting with name in dir
tar -cf archive.tar foo bar - Create archive.tar from files foo
and bar
tar -xf archive.tar - Extract all files from archive.tar.

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 2