Linux Command Line
Linux Command Line
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
mkdir foldername – Create a new folder foldername !! - Repeat the last command
rmdir foldername – Remove an empty folder exit – Log out of current session
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
chmod 777 file - Change file permission of file to 777 grep -o - Show matched part of file only
chown user:group file - Change ownership of file to user and locate file1 - Find file1
group group whereis command - Find binary/source /manual for command
ln -s source destination – Create a symbolic link from source to which app – Locate a command for the app
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
gpg file.gpg - Decrypt file.gpg minutes ago in dir
tar -cf archive.tar foo bar - Create archive.tar from files foo find /dir/ -name name* - Find files starting with name in dir
and bar
tar -cjf archive.tar.bz2 foo bar - Create archive.tar.bz2 from kill pid - Kill process with id pid
files foo and bar, using Bzip2 compression. pkill name - Kill process with name name
tar -xjf archive.tar.bz2 – Extract a tar using Bzip2 killall name - Kill all processes with names beginning name
gzip file1 – Compress file1 and rename it to file1.gz
scp -r foo $USER@$HOST:/bar – Secure copy the folder foo df -h - Show free space on mounted filesystems
from local machine to the folder bar at remote $HOST df -i - Show free inodes on mounted filesystems
Package Installation du -sh folder – Show the total file size of folder
dpkg -i package.deb - Install a deb package fdisk -l - Show disks partitions sizes and types (run as root)
rpm -Uvh package.rpm – Install a rpm package free – Show memory and swap usage