bash command lines

Builtin Bash

echo string string string : multiple string
echo ~ : tilde expansion return user absolute path
echo "string string  string" : single string
echo $((arithmetic operation)) : arithmetic operations support + - * / % **
echo "x"{a,b,c} : xa xb xc brace expansion 
file f1 f2 f3  = file "f"{1,2,3} = file "f"{1..3}
echo $(ls x) : command sustitution syntax
ls dir | sort : pipeline commands 
ls -l *.html : wild card expansion
ls > file :to write output to the file 
ls >> file :to append output to the file 
command .................. &  : to run command in background

what is different between double quote and single quote
double-quote is prevent space expansion and tilde expansion and brace expansion but arithmetic expansion and parameter expansion and command substitution still performed in the other hand single quote will prevent all of them

& after command to let the command execute in the background

&& lets you do something based on whether the previous command completed successfully
for example in c++ if main function return -1 the command on right && never perform

The nohup command executes another program specified as its argument and ignores all SIGHUP (hangup) signals. SIGHUP is a signal that is sent to a process when its controlling terminal is closed.

apt install wget && wget url

for more resources visit

File System

cp originalFile newFile  :  copy original to new 
cp -r originalDir newDir : copy directory recursively

rm file or directory :  remove file or directory
rm -rf  directory :  force remove non-empty directory 
rm -r directory : remove directory recursively 

mkdir directory :  create directory 

mv fileFrom fileTo : move file from to 

ls director : display all directory content
ls -l dir: display files create date and owner and mod
ls -a dir: display all files including files start with dot(.)

cd path: set the current path

pwd : get current path

file filename : get file type like if it text or binary or symbolic link 

dir directory : diplay all directories inside directory

touch file : create file

cat filename file2name : display file content
cat -n filename : display file content with line number
cat > filename : to write to file
cat >> filename : to append to file
less filename : display file content
less -n filename : display file content with line number
head -n number filename : display the first number lines of the content 
tile -n number filename : display the last number lines of the content

ln -s targetfile linkname : create symbolic link for target file
readlink linkname : get the absolute path of the target this file linked to it  

which command : get absolute path for command

chmod {options} filename : change permision of file
chown  USERNAME:GROUPNAME path  :  change owner
chown -R USERNAME:GROUPNAME path : change owner recursive
chgrp group file1 file2 dir1  :  change group of file

zip|unzip file  
cat ./file.txt | grep "^hello .*ld.*$"
user@host:/home/user$ chmod ugo+rwx file4 #add read and write and execute permision for owner and group and others


lspci : pci hardware info
inxi : hardware info more readable need to install
free : memory size and how much used and free
dmesg : debug all devices
lsusb : all serial devices connected
top : monitor all processors
kill -9 pid : force kill for proccesor
ps -aux :to get all arunnig processors


sudo : play command as root
sudo -i : always as root
adduser userName : add user
su : switch user
usermod -aG group user : add user to group
deluser user group : remove user from group
groups : display groups of current user
exit : logout
passwd : change passward of current user
adduser –system userName : add system user
addgroup group : add new group
userdel username : to delete user -r for remove every thing belong to user

note: if you want to add new command move your program to /usr/bin directory