UNIX : Unix is a family of Operating Systems (OS). It is made up of three parts; kernel, shell and programs.
There are different versions of UNIX. Most popular flavor is LINUX. As Linux is is Unix-like system, we can use Unix commands to control it.
Linux is designed by Linus Torvalds in 1990’s and dedicated to open source community. It is also referred as GNU/Linux as it is based on a modified version of GNU (GNU = recursive acronym “GNU is not Unix”)
Linux is used as base for OS like Raspbian.
ls list the files/directories
ls -a list the files/directories including hidden files.
ls -l list the files/directories in long format.
ls -lh list the files/directories in long format. (h = human-readable format of number)
ls –l / list the files/directories in long format of root user.
pwd present working directory
whoami user name
mkdir to make new directory.
mkdir -p make new directory and sub-directory at same time (ex. mkdir -p dir1/dir2)
cd change directory
cd .. change directory to parent (note there is a space between cd and .. )
cd – change directory to previous directory
cd ~ change directory to home-directory`~$ cd – go to previous directory
cd ../.. go to parent’s parent directory (two-level up)
clear clear the screen or using the keyboard ( ctrl+ l )
cp copy
mv move or rename
rm remove (empty file)
rm -rf remove file (non-empty)
rm -Ri i= interactive
rmdir remove directory (empty)
cat concatenation – to display the content of the file on screen
grep it searches files for specified words or patterns.
!! run the previous command
Ex. Sudo !!
sudo !! two exclamation marks belong to previous command run.
uname -s gives kernel name
uname -o gives Operating System name
uname -a gives all of the System information
dmesg | less to show Linux boot messages
cat/proc/cpuinfo to show processor info, model name and cup architecture info.
cat /proc/meminfo info. about memory installed
man -s 1 -k remove ( from manual, section-1, find keyword for removing something)
cat > textfile1 ( send screen input to file name textfile1) (Ref Youtube Link)
ctrl + U = clear content of the command line only
ctrl + A = Bring cursor to start of command line
ctrl + E = Bring cursor to end of command line
ctrl+R = search for previous commands in command prompt.
history = to see command history
!<history command serial number> = execute particular command (ex. !102 )
groups shows list of groups for current user
chmod = Change Mode (two ways – number mode and letter mode)
chmod 777 t1.txt
chmod ugo=rwx t1.txt OR chmod a=rwx t1.txt
chmod ugo-wrx t1.txt OR chmod a-wrx t1.txt
chmod ugo+rx t1.txt OR chmod a+rx t1.txt
chmod -w t1.txt (remove write for all)
chown root t1.txt (change owner of t1.txt file to root)
chgrp root t1.txt (change group of t1.txt file to root)
find
find . -name t1.txt (find a file named t1.txt at current directory)
find . iname t1.txt (i = ignore case)
find . -iname T* -exec ls -l {} \; (exec = execute the command next to it based on input before it)
find . -iname T* -exec rm -rf {} \; (remove all files starting with T or t)
alian (to create another name for a commnad)
ex.
alias c=’clear’
Cron jobs
crontab -l (list all cron jobs)
crontab -l -u root (list of cron jobs for user root)
for ref : (https://crontab.guru/)
sudo
sudo su (change user to root)
sudo su – (change user to root and import all env veriable)
sudo -s
sudo bash
adduser,deluser
adduser test (add new user named test)
adduser test sudo (add user test to sudo group)
sudo su – test (change user to test)
deluser test (delete user test)
deluser test –remove-home (remove home directory of user test)
https://ubuntu.com/tutorials/command-line-for-beginners#1-overview
https://distrowatch.com/dwres.php?resource=major
https://www.freecodecamp.org/news/the-linux-commands-handbook/
https://upload.wikimedia.org/wikipedia/commons/8/83/Linux_Distribution_Timeline_27_02_21.svg
youtube: