LAB 2

 Operating System : Lab 2


Part 1

Type in the command route and press the Enter key. Do the same for uptime, ls, date, and sync, pressing Enter after each command.Now press the up arrow key one time. You should see the following command: sync.

 




Now press up arrow two times. We should see date and ls
 
             






Press enter. The ls command will run again ,pressing enter will always run the command as shown on figure below





Part 2


Run a few commands such as route, uptime, date, and sync.After that run the history command



Instead of typing the command, we can type an exclamation point (!) and then the number of command and press enter. For example !3. It will show in the history listing as shown in figure above.


Part 3

Change home directory 




Create a directory using the following command:




Change to Linuxbook using this command : cd Linuxbook
Then we create some files using the following command :

 ls > file2.txt
 ls > file3.txt
ls > file4.txt
       ls > unique1.txt






Now type ls -al file and press Tab. Nothing will happen, and your console may beep. Press Tab again. Now all 4 filenames will appear.Add a 4, press Tab again, and then Enter. The command ls -la file4 will run







Part 4

When we open the terminal the first thing we see as for me is anislinux@kali.
anislinux@kali is PS1. We use export PS1="\u\h\w\$" command to modify PS1.





It is format string for our prompt

\u = user
\h = hostname
\w= working directory
\$ = symbol represents each command in terminal 





What is PATH ?

PATH=  It shows and sets the directories where programs are searched for 




Prepending a dot to the PATH means the program will be looked for in the current directory first, before searching the rest of the path.

export PATH=".:$PATH"



The EDITOR variable can be set to your favorite text editor. Most people use vi (or vim); however, you can point it to the one you want. If you change this, be sure to   use the full path. To change the EDITOR variable do this:



We can see the difference before and after use the export EDITOR .As we can see when I use export EDITOR= my editor is removed.



Part 5

Type tput clear and press enter. The screen would be clear.






INPUT COMMAND alias cls="tput clear"

This command will set cls to clear the screen






To show a long directory listing enter alias la="ls -la". Enter 'la' to run the alias.

When we enter the ls -la in terminal ,it will list all the directories. Morepver we can use our own command line that does the same work : alias la="ls =la"



To show a long listing with most current files enter alias lt="ls -latr" command




Part 6

We can use aliases to move the file system around efficiently. If you use KaliLinux type 
mkdir -p pi/linukbook in command line and enter.



We created folder name linuxbook in home directory.



alias lbook="cd/home/pi/linuxbook" .Now we created lbook command to open the linuxbook folder as we enter the lbook. (There are some error in the command,my mistake)



But you can see after error was fixed we opens the linuxbook through lbook.



Part 7 

Using export to create alias
Type export lbook="/home/pi/linuxbook"

        alias lbook="cd $LBOOK

         lbook



              


Part 8

In this part, we can use LBOOK variable to copy file to directory. The command that can be used:
cd/tmp
touch f1.txt
cp f1.txt $LBOOK




a. Enter the cd /tmp which temporary directory 
b. Create file which is f1.txt



Comments