roliu_linux-commands-cheat-sheet
roliu_linux-commands-cheat-sheet
pwd - display current working directory which app - shows the full path of the app
touch file - create or update file df -h - show file system disk space usage with human-‐
mkdir dir - create a new directory dir readable storage size
rm file - remove file du -d0 -h dir - display the directory space usage without
displaying subdirectories
nano file - edit the file using Nano's editor
mv file1 file2/dir - rename file1 to file2 or move file1 to dir
Process Management
rmdir dir - remove empty directory dir
ps - display current active processes
rm -r dir - remove directory dir
top - display all running processes
cp file1 file2 - copy file1 to file2
kill pid - kill a process by ID
cp -r dir1 dir2 - copy directory dir1 to dir2 and create dir2 if it
killall procname - kill a process by a name
does not exist
Compression
File Permissions
tar -cvf file.tar files/dir - create a tar file to archive the files/dir
chmod file - change file permission
and display the progress in the terminal.
chmod u-w file - remove the writable permission from file
tar -xzvf file.tar.gz -C dir - extract a tar using Gzip to directory dir
to user
tar -czf file.gz file.tar - compress the file.tar to file.gz using
chmod 777 file - give read, write, execute permission to
Gzip
all
gzip file - compress file and rename it to file.gz
Operator for chmod
gzip -d file.gz - decompress file.gz back to file
+ add the specified modes
- Remove the specified modes from file or Searching
dir
grep pattern files - search for pattern in files, * denotes all
= Set the specified modes
the files
chown user:group file - change the ownership of file
grep -r pattern dir - search for the pattern in dir
grep -i pattern file - ignore the case and search for the
Users and Groups
pattern
groupadd group - add a new group
command | grep pattern - search for the pattern in the output of
useradd -g group nUser - add a new user to group command
usermod -g group eUser - add an existing user to group locate file - find all instances of file by name
lid -g group - list all the users in the group
A regular expression is used to describes a particular search pattern
All the above commands require superuser privileges. .
Network
Redirection