Ubuntu
Ubuntu
ls -l -> This option enables the long listing format, providing detailed
information about each file or directory.
ls -t -> This option sorts the list by modification time, with the newest
files or directories appearing first.
ls -r -> This option reverses the order of the sort, displaying the oldest
files or directories first.
So, "ls -ltr" will list the contents of the current directory in long format, sorted
by modification time, with the oldest files or directories appearing first.
Output:
Commands Used:
➢ Grep Nepal Nepal.txt -> prints the whole line of matched term “Nepal” from
the Nepal.txt file.
➢ grep -o -> prints only matched term
➢ grep -n -> prints matched content with line number
Output:
Commands Used:
➢ sudo -i => runs login shell for current user (prastab)
➢ whoami => prints current user name associated with current
effective user ID
➢ sudo whoami => prints root user
➢ sudo apt-get update => resynchronizes the package index files fromtheir
sources
➢ sudo -l => list user privilege or check a specific command
Output:
Commands Used:
➢ pwd -> prints current working directory
➢ pwd - - help -> prints help menu for pwd
➢ pwd -P -> prints the physical directory without symbolic links
Output:
1.9. Command Name: mv
Commands Used:
➢ mv styles.css css/ -> moves styles.css file to css directory
➢ mv errors.html error.html -> renames errors.html file as error.html
➢ mv -v blogs.html blog.html -> explains what is being done
Output:
Commands Used:
cat index.html -> prints the content of index.html
Output:
1.11. Command Name: chmod
Syntax: chmod [MODE] File
r -> read
w- > write
x- > execute
Usage: used for changing file mode/permissions
Commands Used:
➢ chmod +rwx poem -> adds read,write and execute permissionto poem
➢ chmod -rwx poem -> removes read,write and execute
permission from poem
➢ chmod +x poem -> adds executable permission to poem file
Output:
Usage: used for changing the user and group ownership of file
Commands Used:
➢ chown mark Music/ -> changes ownership of Music folder to
mark.
➢ chown -v root story -> changes ownership to root and prints
diagnostics for it
Output:
1.13. Command Name: clear
Syntax: clear
Commands Used:
➢ clear -> cleans terminal screen
Output:
1.14. Command Name: passwd
Commands Used:
➢ passwd => change current user’s password
➢ sudo passwd Maharjan => change Maharjan’s password
➢ sudo passwd -d Maharjan => delete user’s password
➢ sudo passwd -e Maharjan=> immediately expires an
account’spassword
➢ sudo passwd -q => quiet mode
➢ sudo passwd -u => unlocks the password of the named
account
Output:
1.15. Comma
ndName
:Useradd
Syntax: useradd [options]
Commands Used:
➢ useradd wizard -> creates a new user with the name khonshu
➢ useradd -m mark -> creates the user’s home directory
➢ useradd Life -c “Life is beautiful” -> adds short description of login
Output:
Commands Used:
➢ apt-get update -> resynchronizes the package index files from their
sources
➢ apt-get upgrade -y -> install the newest versions of all packages
currently installed on the system from the sources
➢ apt-get install gimp -> installs gimp software
➢ apt-get purge gimp -> uninstalls gimp
➢ apt-get autoclean -> clears out the local repository of
retrievedpackage files
➢ apt-get autoremove -> removes packages that were automatically
installed to satisfy dependencies for other packages and are now
no longer needed
Output:
1.17. Command Name: apt-get
Syntax: apt-get [options]
Usage: used for handling packages
Commands Used:
apt-get update -> resynchronizes the package index files from theirsources
apt-get upgrade -y -> install the newest versions of all packagescurrently
installed on the system from the sources
apt-get install gimp -> installs gimp software
apt-get purge gimp -> uninstalls gimp
apt-get autoclean -> clears out the local repository of retrievedpackage files
apt-get autoremove -> removes packages that were automaticallyinstalled to
satisfy dependencies for other packages and are now no longer needed
Output:
1.18. Command Name: date
Commands Used:
Date -> prints the current date
date -R -> prints date in RFC format
date +’%a, %b %d’ -> print date in given format
date -d yesterday -> prints yesterday's date
date -u -> prints in UTC format
Output:
1.19. Command Name: time
Commands Used:
time
time -p prints time in POSIX format\
time sleep 5
Output:
Usage: used for create Archive and extract the Archive files
Commands Used:
tar cvf archive.tar -> creates a tar file called `archive.tar` which is the Archive of all
.html files in current directory
tar xf archive.tar -> extracts files from Archives and make a copy of the existed file
tar tf archive.tar -> shows all the files and folder present in the folder
Output:
1.21. Command Name: gzip
Syntax: gzip [Options] [filenames]
Usage: used for compressing files
Commands Used:
gzip -k journel.txt -> creates compressed file of journel.txt named as journel.txt.gz
and also keeps the original file
gzip -d journel.txt.gz -> decompress a file
gzip -vd journel.txt.gz -> displays the name and percentage reduction for each file
decompressed
Output:
1.22. Command Name: kill
Commands Used:
kill -l -> lists signal name
kill 13986 -> process receives a kill signal
Output:
Usage: used for sending signals to the processes of a running program based on given
criteria
Commands Used:
ps aux | grep gedit ->
kill 4947 -> kills processes for 4947
pkill -e chromium-browse -> displays name and PID of the process being killed
(chromium-browse)
Output:
Commands Used:
➢ man echo -> displays manual page for echo
➢ man -f grep -> displays short description about grep
➢ man -k mkdir -> searches the given command as a regular
expression in all the manuals and it returns the manual pageswith
the section number in which it is found
➢ man -w pkill -> returns the location in which the manual
pageof a pkill command is present
Output: