A typical Linux operating system is made up of three parts; the kernel, the shell and the applications.
Kernel: The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the file store and communications in response to system calls.
Shell: The shell acts as an interface between the user and the kernel. When a user logs in(into command line only environment), the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt . A graphical user interface for shell is called Terminal.
Desktop Environment: Linux operating systems also have a graphical user interface (GUI) through which users can access applications and system resources. Unlike other operating systems Linux OSs has many Desktop Environments available. Users are free to install the GUI of their choice. Some popular ones are GNOME, KDE, XFCE, Ubuntu Unity etc. When you install a Linux System it comes with a default GUI. You can install other GUIs any time you want but obviously you can only use one GUI environment at a time. The Kali Linux comes with GNOME.
Linux Directory Structure: In linux files and directories (folders) are laid out on disk in hierarchical fashion in a tree structure. Top directory is called root folder, it is denoted by “/” (slash). The sum of all files and directories in a Linux machine is technically referred as “file-system”.
Path (location) of a file or directory on the file-system is written starting from root the directory (/) followed by all intermediate directory names separated by a slash with the actual file name (or directory name) in the end of the path. Ex: the file path of the file “report.doc” in above figure is written as /home/its/ug1/ee51vn/report.doc
Question 1: Write path for directory staff in above figure
There are different default directories under the / directory which are used for specific purpose.
/bin : all executable binary files (including commands)are present in this directory.
/dev : contains device files for hardware devices (usb, cdrom etc.)
/etc : Contains Application’s configuration files, startup, shutdown, start, stop script for every individual program.
/home : Home directory of the users. Every time a new user is created, a directory in the name of user is created within home the directory which contains other directories like Desktop, Downloads, Documents, etc.
/lib : The Lib directory contains kernel modules and shared library images required to boot the system and run commands in the root file system.
/lost+found : This Directory is installed during installation of Linux, useful for recovering files which may be broken due to unexpected shut-down.
/media : Temporary mount directory is created for removable devices viz., media/cdrom.
/mnt : Temporary mount directory for mounting file system.
/opt : Optional is abbreviated as opt. Contains third party application software. Viz., Java, etc.
/proc : A virtual and pseudo file-system which contains information about running process with a particular Process-id aka pid.
There is huge number of flavors of Linux Operating Systems i.e. Linux is not a single operating system. But all of them are created from same Linux Kernel. An estimate is there are around 3500 types of Linux OSs! such as Kali, Redhat, Ubuntu, Debian, CentOS etc.
You will use Ubuntu 20.04 for this lab
You can download the OS from OSboxes.org.
Use following credential for OS login
Password : osboxes.org
Sudo Password: osboxes.org
Alternately, you can download the zipped version of image from this link Download the VDI from this link : https://sourceforge.net/projects/osboxes/files/v/vb/55-U-u/20.04/Ubnt-20.04-VB-64bit.7z/download
You need to install virtualbox from this link:
Download ubuntu 20.04 from osboxes.org and extract the file in a drive/folder. Now create a virtual machine in virtual box. Click on Machine-> New
On Create Virtual machine window give a suitable name select machine folder, select type “Linux” and Version “Ubuntu 64 bit” and click Next
Provide at least 2 gb ram and click Next
Select “Use an existing virtual hard disk file” and click on the icon as shown below
Press Add button and add the disk image previously downloaded/extracted from osboxes.and click on open as shown below
Select ubuntu 20.04 from the hard disk selector window and click on “choose”
Now, click on create
Now start the machine
Go to the Network section and change the Attached to NAT
Press Ok button and go again to the Machine option and press Reset.
This is how the default desktop environment on a Ubuntu 20.04 Desktop OS looks like.
The text [email protected]:~$ is the shell prompt. It means user osboxes, is logged into machine osboxes. $ indicates normal user. If you find # instead of $ then it is a root user.
The ~ (tilde) symbol indicates that the user is currently in his home directory. For the root user the home directory is /root. For the user “osboxes” the home directory would be /home/osboxes. In later sections I’ll explain the difference between a super user root and a normal user.
Linux Command Format:
A typical linux command has 3 parts: command, options and arguments. Options starts with “-“ symbol (hyphen or minus symbol). There are always spaces in between command, option and arguments
Ex: “ls -l /home”. In this “ls” is command, “–l” is option, “/home” is argument. This command lists all file and folders in the folder /home. Note that there are always spaces in between command, arguments and options. You have to type this command in this way: ls<space>-l<space>/home.
Note: Passwords are not shown in terminal as you type them. Usually while typing password you’ll see *****(stars) or in ……… (dots). But here you don’t see anything on a Linux Terminal.
Ex: passwd alice
Username ALL=(ALL:ALL) ALL. You add this line next to line the
root ALL=(ALL:ALL) ALL. My username is alice. You have to give your newly created username.
In the new window click Restart
Question 2: Login to your new user account, open a terminal and type “sudo su”, enter sudo password for your account, and submit a screen shot. Screenshot should clearly show the prompt. It looks like [email protected]:/home/alice.
Note: the user password is asked when you use the “sudo” command for first time in a terminal. “sudo” is used to elevate a normal user to root user for execution certain high privilege commands.
Question 3: Type “tail /etc/passwd” (/etc/password is one string –no spaces in between.)
Submit a screenshot of the above step.
Root user is administrator of system and has full privileges by default, while normal user has limited privileges. He is referred to super user in Linux. Normal user need to use “sudo” command to gain certain high privilege commands, temporarily. Ex: to install software, to change to root user in terminal, to change system settings etc.
Type “pwd” at command prompt (without quotes). This command displays the directory in which you are currently. When a user starts a shell the default directory is user’s home directory: /home/username. (Username is your login name with which you logs into the Kali VM).
This command is used to change to a desired directory from current directory.
“cd .” keeps you in same directory, while “cd ..” moves to parent directory, a level above. “cd ../..” moves you two levels above the current directory.
ls command simply lists file and directories in present directories. Option “–l” which gives more details about files which include file size, time created, file permissions etc
To display details of a directory or file: ls –l directory or file name. Ex: ls –l Desktop
Question 4: what output “ls –la” gives (take a screenshot)? What difference did you observer between the results of ls –l and ls –la? What is option “–a” means (hint: refer to man page: man ls. See man help section below. Or you can just google)
Type the following commands in order
“touch file4” .Creates a file
“mkdir dir4” .creates a directory dir4
“cp file4 dir4” .copies file4 to dir4
“mkdir dir5” .creates another directory dir5
“cp –r dir4 dir5” .Copies dir4 to dir5
Question 5: Why do we have to use “-r” option to copy directories (Hint use man cp)?
Question 6: What is the result?
You are searching for file called file1 in directory /root. This command will search for the file in /root and in all its sub directories. You gave /root as search location as you think file1 must be somewhere in it. You are totally clueless where the might be on file system, you should start searching for it from top most directory in file-system, i.e /. the command would be find / -name file1
Absolute and relative path
Either way you are able can access dir44
Note: Relative path only makes sense if the object you are accessing below your current directory. Else you have to use the Absolute path. For example, you have to access /etc/wireshark/init.lua file, you don’t have any relative path to it from your home directory. But you can use a relative path you are in / or /etc.
Note: For “tar” command, you should supply output filename along with .tar extension. For gzip, it automatically creates a zipped file with .gz extension. You no longer have .tar file after you compress it with gzip.
type “tar –zcvf compressed2.tar.gz a b c d”.
“man” command is used to get help for any command in Linux. man stands for manual. To pull up a man page of a command, type man command. Ex: man ls. This command displays list of options available with the command. Man pages explain different options and syntax of a command and are usually difficult to understand for beginners. If you want to know usage and example for a command, google is the best place to look.
Type “q” to quit from man page.
In Linux a file has read, write and execute permissions. And permissions are assigned to users of three categories: owner, group and others. The user who creates a file will be the owner, group is group of users who has access. Others are all the users other than owner and users in the group
Type ls –l filename to list file permissions.
Below illustration explains various fields of a file details printed
Each file (and directory) has associated access rights, which may be found by typing ls -l. Also, ls -lg gives additional information as to which group owns the file (beng95 in the following example):
-rwxrw-r– 1 ee51ab beng95 2450 Sept29 11:52 file1
In the left-hand column is a 10 symbol string consisting of the symbols d, r, w, x, -, and, occasionally, s or S. If d is present, it will be at the left hand end of the string, and indicates a directory: otherwise – will be the starting symbol of the string.
The 9 remaining symbols indicate the permissions, or access rights, and are taken as three groups of 3.
The symbols r, w, etc., have slightly different meanings depending on whether they refer to a simple file or to a directory.
|-rwxrwxrwx||a file that everyone can read, write and execute (and delete).|
|-rw——-||a file that only the owner can read and write – no-one else
can read or write and no-one has execution rights (e.g. your
|w||write (and delete)|
|x||execute (and access directory)|
|–||take away permission|
type “sudo chmod go-rwx access”. This will leave the other permissions unaffected.
Type “sudo chmod a+rw access”
Question 7: Submit a screen shot of terminal
Note that chown only change owner of directory but not its contents. To change ownership of files and directories within own_dir, along with is permissions use chown with “–R” option.
Ex: “sudo chown –R bob:bob own_dir”
It checks for file size to be downloaded and ask for confirmation. Type “y” and hit enter. This command installs Chromium web browser.
Question 8: Take a screenshot of the notification that installation is complete.
If you don’t know the exact name of the package you can search for it with “apt-cache” command
Ex: apt-cache search openoffice. Relevant packages will be shown.
You can also install software using Ubuntu Application icon on desktop
This will down the pdf file. Similarly, you can down load file from web page if its URL is known.
Type “nano newfile”. This will open a blank file called newfile.
If there is already a file by name newfile nano will open that. Only if there exists no file by the name supplied it opens a new blank file with the supplied name.
To write data to file, move cursor with arrow keys to location where you want to add content and start writing. Delete content using backspace.
Press Ctrl+O, it ask for confirmation: File name to write: newfile. Hit Enter.
Press Ctrl+W. A search: prompt appears at the bottom, type keyword you want to search and press enter.
Note: You have all the above explained controls at the bottom of the nano editor with brief description
VI Editor has 2 different modes: Command Mode and Insert Mode.
Type: “vi blankfile”. This opens a new file-blank file if a file doesn’t exist by the name. A file is opened into command mode by default. In this mode you can issue commands to edit text.
Hit letter “i”, which moves to insert mode from command mode. You can edit, add content to the file in this mode. Use arrow keys to navigate, backspace to delete.
To save changes to the file:
Note: If you don’t want save the file at this point but want to go back , hit escape-to go to command mode and then “i” to go to insert mode. You always have to be in command mode before you go to insert mode.
There are many other text editors like emacs, pico etc, but we limit our demonstration to nano and vi. There are many GUI test editors as well. A of couple them I mentioned in Kali Linux Intro Section.
This is not an exhaustive list of commands. But this list covers most of the commands which are regularly used.Note: Always use the command “man” to view a command’s manual pages. The command’s manual page gives a complete list of functional usage of a command. a alias Create an alias of a command apropos Search Help manual pages (man -k) apt-get Search for and install software packages (Debian/Ubuntu for Centos use yum) aptitude Search for and install software packages (Debian/Ubuntu) aspell Spell Checker awk Find and Replace text, database sort/validate/indexb basename Strip directory and suffix from filenames bash GNU Bourne-Again SHell bc Arbitrary precision calculator language bg Send to background break Exit from a loop • builtin Run a shell builtin bzip2 Compress or decompress named file(s)c cal Display a calendar case Conditionally perform a command cat Concatenate and print (display) the content of files cd Change Directory cfdisk Partition table manipulator for Linux chgrp Change group ownership chmod Change access permissions chown Change file owner and group chroot Run a command with a different root directory chkconfig System services (runlevel) cksum Print CRC checksum and byte counts clear Clear terminal screen cmp Compare two files comm Compare two sorted files line by line command Run a command – ignoring shell functions • continue Resume the next iteration of a loop • cp Copy one or more files to another location cron Daemon to execute scheduled commands crontab Schedule a command to run at a later time csplit Split a file into context-determined pieces cut Divide a file into several partsd date Display or change the date & time dc Desk Calculator dd Convert and copy a file, write disk headers, boot records ddrescue Data recovery tool declare Declare variables and give them attributes • df Display free disk space diff Display the differences between two files diff3 Show differences among three files dig DNS lookup dir Briefly list directory contents dircolors Colour setup for `ls’ dirname Convert a full pathname to just a path dirs Display list of remembered directories dmesg Print kernel & driver messages du Estimate file space usagee echo Display message on screen • egrep Search file(s) for lines that match an extended expression eject Eject removable media enable Enable and disable builtin shell commands • env Environment variables ethtool Ethernet card settings eval Evaluate several commands/arguments exec Execute a command exit Exit the shell expect Automate arbitrary applications accessed over a terminal expand Convert tabs to spaces export Set an environment variable expr Evaluate expressionsf false Do nothing, unsuccessfully fdformat Low-level format a floppy disk fdisk Partition table manipulator for Linux fg Send job to foreground fgrep Search file(s) for lines that match a fixed string file Determine file type find Search for files that meet a desired criteria fmt Reformat paragraph text fold Wrap text to fit a specified width. for Expand words, and execute commands format Format disks or tapes free Display memory usage fsck File system consistency check and repair ftp File Transfer Protocol function Define Function Macros fuser Identify/kill the process that is accessing a fileg gawk Find and Replace text within file(s) getopts Parse positional parameters grep Search file(s) for lines that match a given pattern groupadd Add a user security group groupdel Delete a group groupmod Modify a group groups Print group names a user is in gzip Compress or decompress named file(s)h hash Remember the full pathname of a name argument head Output the first part of file(s) help Display help for a built-in command • history Command History hostname Print or set system namei iconv Convert the character set of a file id Print user and group id’s if Conditionally perform a command ifconfig Configure a network interface ifdown Stop a network interface ifup Start a network interface up import Capture an X server screen and save the image to file install Copy files and set attributesj jobs List active jobs • join Join lines on a common fieldk kill Stop a process from running killall Kill processes by namel less Display output one screen at a time let Perform arithmetic on shell variables • link Create a link to a file ln Create a symbolic link to a file local Create variables • locate Find files logname Print current login name logout Exit a login shell • look Display lines beginning with a given string lpc Line printer control program lpr Off line print lprint Print a file lprintd Abort a print job lprintq List the print queue lprm Remove jobs from the print queue ls List information about file(s) lsof List open filesm make Recompile a group of programs man Help manual mkdir Create new folder(s) mkfifo Make FIFOs (named pipes) mkisofs Create an hybrid ISO9660/JOLIET/HFS filesystem mknod Make block or character special files more Display output one screen at a time mount Mount a file system mtools Manipulate MS-DOS files mtr Network diagnostics (traceroute/ping) mv Move or rename files or directories mmv Mass Move and rename (files)n netstat Networking information nice Set the priority of a command or job nl Number lines and write files nohup Run a command immune to hangups notify-send Send desktop notifications nslookup Query Internet name servers interactivelyo open Open a file in its default application op Operator access p passwd Modify a user password paste Merge lines of files pathchk Check file name portability ping Test a network connection pkill Stop processes from running popd Restore the previous value of the current directory pr Prepare files for printing printcap Printer capability database printenv Print environment variables printf Format and print data • ps Process status pushd Save and then change the current directory pv Monitor the progress of data through a pipe pwd Print Working Directoryq quota Display disk usage and limits quotacheck Scan a file system for disk usage quotactl Set disk quotasr ram ram disk device rcp Copy files between two machines read Read a line from standard input • readarray Read from stdin into an array variable • readonly Mark variables/functions as readonly reboot Reboot the system rename Rename files renice Alter priority of running processes remsync Synchronize remote files via email return Exit a shell function rev Reverse lines of a file rm Remove files rmdir Remove folder(s) rsync Remote file copy (Synchronize file trees)s screen Multiplex terminal, run remote shells via ssh scp Secure copy (remote file copy) sdiff Merge two files interactively sed Stream Editor select Accept keyboard input seq Print numeric sequences set Manipulate shell variables and functions sftp Secure File Transfer Program shift Shift positional parameters shopt Shell Options shutdown Shutdown or restart linux sleep Delay for a specified time slocate Find files sort Sort text files source Run commands from a file ‘.’ split Split a file into fixed-size pieces ssh Secure Shell client (remote login program) strace Trace system calls and signals su Substitute user identity sudo Execute a command as another user sum Print a checksum for a file suspend Suspend execution of this shell • sync Synchronize data on disk with memoryt tail Output the last part of file tar Store, list or extract files in an archive tee Redirect output to multiple files test Evaluate a conditional expression time Measure Program running time timeout Run a command with a time limit times User and system times touch Change file timestamps top List processes running on the system traceroute Trace Route to Host trap Run a command when a signal is set(bourne) tr Translate, squeeze, and/or delete characters true Do nothing, successfully tsort Topological sort tty Print filename of terminal on stdin type Describe a command •u ulimit Limit user resources • umask Users file creation mask umount Unmount a device unalias Remove an alias • uname Print system information unexpand Convert spaces to tabs uniq Uniquify files units Convert units from one scale to another unset Remove variable or function names unshar Unpack shell archive scripts until Execute commands (until error) uptime Show uptime useradd Create new user account userdel Delete a user account usermod Modify user account users List users currently logged in uuencode Encode a binary file uudecode Decode a file created by uuencodev v Verbosely list directory contents (`ls -l -b’) vdir Verbosely list directory contents (`ls -l -b’) vi Text Editor vmstat Report virtual memory statisticsw wait Wait for a process to complete • watch Execute/display a program periodically wc Print byte, word, and line counts whereis Search the user’s $path, man pages and source files for a program which Search the user’s $path for a program file while Execute commands who Print all usernames currently logged in whoami Print the current user id and name (`id -un’) wget Retrieve web pages or files via HTTP, HTTPS or FTP write Send a message to another user x xargs Execute utility, passing constructed argument list(s) xdg-open Open a file or URL in the user’s preferred application. yes Print a string until interrupted zip Package and compress (archive) files. . Run a command script in the current shell !! Run the last command again # Comment / Remark // Comment / Remark
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more