List of contents
- General commands
- Bash/Terminal related commands
- Permission related commands
- APT(Package manager) commands
- Tar commands
- Grep commands
pwd
ls
cd ..
cd <folder name>
mkdir <directory name>
touch <filename>
rmdir <directory name>
rm -d <directory name>
rm <directory name>
rm -r <directory name>
rm -rf <directory name>
man <command name>
<command name> --help
cp <filename> <destination>
mv <filename> <destination>
mv <filename> <new name>
locate <file/folder word>
locate -i <file/folder word>
locate -i *<word>*<word>
echo <text> >> <filename>
cat <filename>
sudo halt
sudo reboot
nano <filename>
vi <filename>
jed <filename>
sudo <command>
sudo bash
su
sudo passwd
df
df -m
du
df <file/folder name>
ls -lah
zip <foldername>
unzip <foldername>
uname
uname -a
hostname
hostname -I
ping <server>
rm <filename>
rm <filename> <filename> <filename>
rm *.pdf
rm -i <filename>
rm -f <filename>
sudo -i
sudo adduser <username> sudo
sudo passwd root
sudo visudo
date
uptime
cat <filename>
cat <filename> <filename>
wc <filename>
diff <filename> <filename>
less <filename>
sed -i 's/<text to replace>/<text to be replaced>/g' <filename>
info <command>
Ex: info grep
man <command>
Ex: man grep
logout
shutdown -h now
shutdown -r now
alias
alias [name="value"]
Ex: alias p="pwd"
unalias <alias_name>
bash --version
history
export <MYVAR>=<VARVALUE>
unset <MYVAR>
➤ Update current session with changes made in .bashrc
/ .bash_profile
/ bash.bashrc
/ /etc/profile
file
source .bashrc
source .bash_profile
source bash.bashrc
source /etc/profile
clear
exit
CTRL + R
env
Step 1: Add dir to ~/.bash_profile
echo 'export PATH="$PATH:[NEW_DIR_LOCATION_TO_ADD_TO_PATH]”’ >> ~/.bash_profile
Step 2: Reload to make the changes available to the current shell
source ~/.bash_profile
Or
. ~/.bash_profile
Step 3: Verify that the directory is in the $PATH
echo $PATH
chmod +x <filename>
chmod 755 <filename>
chmod +x <filename>
apt-get <package name>
apt-get update
apt-get upgrade
apt-get install --only-upgrade <Package Name>
apt-get dist-upgrade
apt-cache search <package name>
tar cvf archive_name.tar dirname/
tar cvfz archive_name.tar.gz dirname/
tar cvfz archive_name.tgz dirname/
tar cvfj archive_name.tar.bz2 dirname/
tar cvfj archive_name.tb2 dirname/
tar cvfj archive_name.tbz dirname/
Description:
Term | Description |
---|---|
c | Create a new archive |
v | Verbosely list files which are processed |
f | Following is the archive file name |
z | Filter the archive through gzip |
j | Filter the archive through bzip2 |
NB:
.tgz
is same as.tar.gz
.tb2
and.tbz
are same as.tar.bz2
bzip2
takes more time to compress and decompress thangzip
. Butbzip2
archival size is less thangzip
tar xvf archive_name.tar
Description:
Term | Description |
---|---|
x | Extract files from archive |
tar xvfz archive_name.tar.gz
tar xvfj archive_name.tar.gz
NB:
- In all above commands,
v
is optional
tar tvf archive_name.tar
grep -i "the" demo_file