S E C T I O N O V E R V I E W

Size: px
Start display at page:

Download "S E C T I O N O V E R V I E W"

Transcription

1 PROGRAM CONTROL, FILE ARCHIVING, ENVIRONMENT AND SCRIPTS S E C T I O N O V E R V I E W Continuing from last section, we are going to learn about the following concepts: controlling programs; working with the UNIX environment and environment variables; introducing the notion of scripts; archiving and compressing files. 6.1 ARCHIVING FILES There are times we need to transfer files or even directories at once. Moreover, we may also need to send them as attachments to other users who are located all over the globe. Sometimes, we may also wish to store sensitive information in a safe place, just to make sure we can retrieve this information back, in case our computing system crashes. Although, this is easy there are some obstacles that stem from space limitations and interoperability issues. For example, we may not be allowed to attach large files in an or we may need to transfer our files through a very slow logical connection. Moreover, different operating systems and machines store data in different formats. In order to address these issues, UNIX developers have been implemented two commands known as tar (tape archive) and cpio (copy in out). These commands are capable of archiving any file that exists in a directory and can store data used to describe its structure. The outcome of using these commands is a single file known as archive. Both commands can create archives; however these archives have different format and work with a PAGE 1

2 different way. This may generate problems to users. For instance, some of these users may be familiar with tar and some others with cpio. Despite the fact that tar has been used more frequently than cpio, developers decided to develop a new archiving command that combines functionalities from both programs. This resulted in the development of pax (portable archive exchange). The syntax of these archiving commands is described in syntax 6.1 section. The syntax of cpio command which is rarely used and therefore it is omitted. SYNTAX tar, pax pax option(s) <directory> <arguments> tar option(s) <directory> <arguments> SYNTAX 6.1: tar and pax SYNTAX In addition to the syntax of these UNIX commands. PAX TAR DESCRIPTION w c Create file f f Filename follows t Lists contents in a tar file v v Verbose - display contents as it is tarring or extracting r x Extract the contents of the TAR file z Uncompress it before extracting (gunzip). Typically used with files ending in.tar.gz or.tgz u Copies a file only if it is newer p Preserves file access o Assigns ownership to the user running tar command TABLE 5.1: TAR AND PAX: SOME AVAILABLE OPTIONS Although, there are more than these options listed in table 6.1, we provide some that are used regularly. Users may also like to have a look into the manual pages for these commands available by executing man with given argument the name of the command. Moreover, note that instead of using the f option, we can use the input and output redirection characters, as well. This will forward output or input to a file with a given filename or ouput can be redirected to a device such as a floppy drive or another kind of storage. PAGE 2

3 6.1 ARCHIVING WITH tar and pax Now, let us assume that we need to archive a directory that contains important information. In the following example, we initially use the pax command and then we continue with tar command. EXAMPLE tar, pax 10 tiger% ls -l total 31 -rw svigkoi staff 129 May 24 16:59 hmyfile -rw svigkoi staff 129 May 24 16:59 myfile lrwxrwxrwx 1 svigkoi staff 6 May 24 18:33 smyfile -> myfile45 tiger% pax -wf archive.pax./ 11 tiger% pax -wf archive.pax./ 12 tiger% ls l total 32 -rw svigkoi staff 4096 May 24 18:33 archive.pax -rw svigkoi staff 129 May 24 16:59 hmyfile -rw svigkoi staff 129 May 24 16:59 myfile lrwxrwxrwx 1 svigkoi staff 6 May 24 18:33 smyfile -> myfile45 tiger% pax -wf archive.pax./ 48 tiger% wc -c archive.pax 4096 archive.pax SAMPLE OUTPUT 6.1: pax ARCHIVING COMMANDS In the example provided, we used the command pax -wf archive.pax./ in order to archive the contents of our current directory. The option w instructed pax to create a new archive while f indicated that the archive should be a file. The argument archive.pax is the file name of the archive that was created. The last argument entered is./ and indicated pax command the directory we wish to archive. Note that we also introduced a suffix to the given filename. Although, it is not necessary, we intentionally did that in order to indicate this is an archive file. However, any suffix is optional. Similarly, we provide an example for tar command. The options used are different in comparison to pax. Moreover, in order to archive our current directory, we move out of it as this is recommended. PAGE 3

4 17 tiger% tar -cvf archive.tar./tar_example./tar_example/./tar_example/myfile./tar_example/smyfile./tar_example/hmyfile 18 tiger% ls l -rw svigkoi staff May 24 19:44 archive.tar drwx svigkoi staff 512 Dec ns_imap drwx svigkoi staff 512 Dec nsmail drwx svigkoi staff 512 May 19 11:01 one 19 tiger% wc c mytar.tar mytar.tar 20 tiger% SAMPLE OUTPUT 6.2: tar ARCHIVING COMMAND The command found in sample output 6.2 allowed us to create an archive. As shown, tar is the command used, -cvf are options, we used; archive.tar corresponds to the name of the archive that we wished to create while the./tar_example refers to the directory, we want to back up. Checking carefully the options entered we observe that c indicates that we wish to create an archive. The second option used v allowed us to have information about files that were being archived. This information was being displayed on the terminal window. The last option indicates our instructions to create a file instead for example sending tar s output to a device such as a floppy drive EXTRACTING ARCHIVE FILES USING tar and pax After archiving files, we may also need to extract their contents for future use. This action also applies if we receive an archive file from someone else. In order to extract archive files we use exactly the same commands elaborated previously. However, any options entered should be slightly different. In this subsection, we describe the process of extracting contents from archive files using pax and tar, respectively. PAGE 4

5 31 tiger% pax -rf../archive.pax 32 tiger% ls -l total 8 -rw svigkoi staff 0 May 24 20:47 archive.pax -rw svigkoi staff 165 May 24 20:45 file1 33 tiger% SAMPLE OUTPUT 6.3: EXTRACTING FILES FROM ARCHIVES USING pax In sample output 6.3, we extracted into our current directory the contents of the archive file archive.pax. The options used rf indicate that r stands for read and f indicated that the following argument is an archive file. Typing ls l we can see that the contents of the archive archive.pax were extracted. These are archive.pax and file1. The archive file used was located in our parent directory. One important observation here is that our archive file includes the archive file, we wished to extract. This generated a problem resulting in having a file (archive.pax) with zero bytes (empty file). Therefore, it is a common practice we should never archive a directory we are currently in or extracting archives that also contain our archive file in. A common practice for the avoidance of such as these problems is that if we wish to archive our current directory we move one directory up to our parent directory and then we perform the archiving process. In a similar fashion, we also provide some examples that correspond to tar command. 56 tiger% tar -xvf../my_dir_archive.tar./my_dir_archive/./my_dir_archive/file1./my_dir_archive/archive.pac 57 tiger% ls my_dir_archive 58 tiger% SAMPLE OUTPUT 6.4: EXTRACTING FILES FROM ARCHIVES USING pax The most important point here is the options used, namely xvf. The first character from left stands for extract. In other words indicated tar command to extract an archive. The second stands for verbose and dictates tar PAGE 5

6 to provide a list of all contents being extracted while option f indicates that a file given as argument follows. Note that our archive is located in our parent directory. 6.2 COMPRESSING AND UNCOMPRESSING FILES In an attempt to find out the size of the archived files created by the pax and tar commands, we can easily understand their usability. However, we can also conclude that files created are bigger in size than the size of the all files contained in the directory, we archived. This is because of that these archiving commands store additional information in archive files that reflect the structure of files and sub-directories included in a directory. At this point, we may also have an obvious question like Can we compress an archive file in order to reduce its output?. The answer, of course, is positive. 6.1 COMPRESSING FILES The command for compressing files is known as compress and is used to reduce the size of archives. The syntax is shown bellow: compress [-c] [-f] [-v] <filename(s)> SYNTAX 6.2: tar and pax SYNTAX table: The available options of this command are described in the following OPTION DESCRIPTION w f v It writes to the standard output and no files are changed. No.Z files are created. When compressing, force compression of file. Does not consider if file does not actually reduce the size or if there is an existed filename suffixed with.z. In case -f option is not given and provided that the process is not running in the background, compress prompts to verify whether an existing file.z file should be overwritten. Verbose output that Shows you how much the file shrank in size. TABLE 5.2: UNCOMPRESS: AVAILABLE OPTIONS We provide an example to describe how compress command works. Consider the following output: PAGE 6

7 83 tiger% ls -ld arc* drwx svigkoi staff 512 May 24 22:07 archive -rw svigkoi staff May 24 22:14 archive.tar 84 tiger% compress archive.tar 85 tiger% ls -ld arc* drwx svigkoi staff 512 May 24 22:07 archive -rw svigkoi staff 745 May 24 22:14 archive.tar.z 86 tiger% SAMPLE OUTPUT 6.5: COMPRESSING ARCHIVES USING compress As shown in the sample output 6.5, we first used ls ld arc* to display all files that match the expression entered. As we as interested in compressing a tar file, we executed the command compress archive.tar. By executing ls ld arc*, we can see that a new file was created with filename archive.tar.z. The file given as argument to the compress command was deleted automatically. This is the way compress command works. After compressing a file, compress deletes it and outputs a file which is compressed with filename the name of the old file concatenated with the suffix.z. Of course, we can also see that the compressed file is much more less in size in comparison with the original uncompressed one. 6.2 UNCOMPRESSING FILES Compressed files can be uncompressed with uncompress command. We omit the description of its syntax and options available as they are almost identical with compress command. However, we provide an example to demonstrate its functionality. 87 tiger% ls ld arc* -rw svigkoi staff 745 May 24 22:14 archive.tar.z 88 tiger% uncompress archive.tar.z 89 tiger% ls -ld arc* -rw svigkoi staff May 24 22:14 my_dir_archive.tar 90 tiger% wc -c my_dir_archive.tar my_dir_archive.tar 91 tiger% SAMPLE OUTPUT 6.6: UNCOMPRESSING ARCHIVES USING uncompress PAGE 7

8 Initially, we instructed the shell to display information regarding archive.tar.z. As shown, the size of the compressed file is 745 bytes. Then, we used the uncompressed archive.tar.z command and we uncompressed the corresponding file. The wc c archive showed us the size of the uncompressed file which is significantly larger that the.z one. SAMPLE OUTPUT 6.5: COMPRESSING ARCHIVES USING compress 6.3 WORKING WITH ENVIRONMENT In UNIX and other operating systems, there is a notion known as environment. This is a communication mechanism that allows the system itself and users to locate various commands that are dispersed across directories. Moreover, it is also used for other settings. In general, the environment is just a set of variable names that usually contain values. However, the notion of type (i.e. integer, string etc) is missing. In fact, variables are considered as sequences of strings while they can be interpreted as numbers in some circumstances and when this is necessary ENVIRONMENT VARIABLES So far, we have seen the use of some environment variables. Moreover, we also had the opportunity to work with them by assigning different values into them. Perhaps, you remember that by changing the value of environment variable prompt we can modify our shell command prompt. Environment variables are structured by block capital letters for convention while as we already know filenames and directories names are expressed by small case letters. There are several environment variables we may need to consider. Some of them may have been already defined while others may have been not. Moreover, some of them are used in specific shells while in others they are not. VARIABLE NAME DESCRIPTION DISPLAY EDITOR HOME LOGNAME MANPATH PAGER It indicated where the X-Windows output is forwarded. It is usually set up based on the machine s IP you log in. It reflects the editor which is used whenever a program calls for a file to be edited. It can be set up for using vi or emacs or others such as pico. It corresponds to the absolute pathname of your home directory. It refers to a user s login name. It corresponds to the search path that is used when locating a man page. It has a similar purpose like PATH but it is used only for man pages. It refers to the program that is used by some other commands i.e. the man PAGE 8

9 PATH PRINTER PS1 PS2 SHELL TERM VISUAL command. The actual command referred actually displays the output of a file or a command. For example, one of these pager commands is the more command while others include the less as an alternative etc. It is the search path that is used for locating a command or a program. Each entry is by colons (:). This variable is set automatically as it serves an important role. However, it can be altered according to user s need. However, any changes planned are not recommended for inexperienced users. Changes can be performed only for a login session or permanently. The latter case corresponds to changes should be made in cshrc. It refers to your default printer It refers to the shell command prompt. It refers to the shell command continuation prompt. It corresponds to the pathname of the shell you use. It hodls a value that reflects the terminal window you use. It has the same purpose like the EDITOR environment variable. TABLE 5.3: DETAILED LIST: ENVIRONMENT VARIABLES One of the most important is the PATH variable. The reason behind this claim is that every command used is found through this indexing notion. In fact, after typing a command the operating system consults the PATH variable and checks each entry known as pathname component. If the corresponding program or command is found in these path components then is executed otherwise an error is generated. We can see the contents of each variable individually or we can have a list that contains all of them. So far, we have seen the first approach which is carried out by entering in our command prompt: echo $PATH This results in displaying the value of PATH variable. The second approach is to type: env more By entering this command, you will be able to see all environment variables set for you. Note that in the above example, we also used the pager more just to make sure any given output that does not fit in the terminal, will be displayed after pressing a button. A possible output you can get is similar to the following: PAGE 9

10 2 tiger% env USER=tom LOGNAME=tom HOME=/home/impala/u2/staff001/tom SHELL=/bin/csh TZ=GB-Eire SSH_CLIENT= SSH_TTY=/dev/pts/41 TERM=vt100 DISPLAY=tiger:10.0 PWD=/home/impala/u2/staff001/tom MANPATH=/usr/local/man:/usr/man:/usr/share/man:/usr/openwin/man:/opt/SUNWspro/man:/opt/SUNWs pro_4.0/man:/opt/gnu/man:/opt/epc/man LD_LIBRARY_PATH=/opt/SUNWspro/lib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:/usr/local/rvplayer5. 0 OPENWINHOME=/usr/openwin PATH=/usr/local/bin:/home/impala/u1/staff001/tom/bin:/bin:/usr/ccs/bin:/opt/SUNWspro/bin:/opt/SUNW spro_4.0/bin:/usr/openwin/bin:/opt/gnu/bin:/usr/ucb:/usr/local/rvplayer5.0 SAMPLE OUTPUT 6.7: UNCOMPRESSING ARCHIVES USING uncompress We can observe that there are some environment variables that we have not described so far. However, this is out of the scope of this document. Some of these variables may be set up by the organisation which uses UNIX and may serve some specific purposes for it. Note that we can also introduce our environment variables as well. Perhaps, some of them can be used by our shell scripts or applications we will create GLOBAL AND LOCAL VARIABLES Environment variables have a global scope. However, if a user or a process assigns a value to a variable, this value has a local scope. This is due to that these kind of values cannot be passed to the parent process i.e. processes that initialised a process. Of course, these values may be passed to child processes i.e. processes that a given process has initialised. Typically, when we set up a variable by assigning a value to it, we use the set command. However, this command refers to a variable with local scope. The solution is the use of setenv command. Any variable introduced can be used by parent and child processes. PAGE 10

11 5 tiger% set MY_NUMBER_ONE = "Helena" 6 tiger% echo $MY_NUMBER_ONE Helena 7 tiger% sh $ echo $MY_NUMBER_ONE $ csh 1 tiger% echo $MY_NUMBER_ONE MY_NUMBER_ONE: Undefined variable 2 tiger% setenv MY_NUMBER_ONE "Helena" 3 tiger% echo $MY_NUMBER_ONE Helena 4 tiger% sh $ echo $MY_NUMBER_ONE Helena $ csh 1 tiger% echo $MY_NUMBER_ONE Helena 2 tiger% SAMPLE OUTPUT 6.8: WORKING WITH GLOBAL AND LOCAL VARIABLES By setting MY_NUMBER_ONE = "Helena", we defined a new variable called MY_NUMBER_ONE and assigned into it the value Helena. Then we used echo in order to echo its value in the terminal display. However, after switching to Bourne shell by typing sh we realised that our variable does not exist. This is the reason, we obtained an empty line. We switched back to C Shell and tried to echo our previously defined variable. At this point, we received an error message MY_NUMBER_ONE: Undefined variable. The problem generated because MY_NUMBER_ONE had a local scope. We redefined our variable by using setenv MY_NUMBER_ONE "Helena" and repeated the previously elaborated steps. Since our variable now has a global scope it can be used by other processes. SCOPE C SHELL BOURNE SHELL Local Scope set <Variable_name>=value; Global Scope setenv <VARIABLE_NAME>=value; export <VARIABLE_NAME> (Korn or Bourne shell) TABLE 5.4: SETTING UP GLOBAL AND LOCAL VARIABLES PAGE 11

12 Table 5.4 summarises any commands related with setting variables with global or local scope for Bourne and C shells. The syntax of these commands is explained below. Moreover, note that we also describe the syntax of the command unset. This command that the opposite effects when used, foe example if there is a variable already set, unset will delete a variable with a name given as argument. C Shell set myvar = place value here setenv <variable_name> <value> unsetenv VARIABLE_NAME value Bourne Shell <viariable_name>=<value> export <variable_name> unset VARIABLE_NAME SYNTAX 6.2: set, setenv, unset SYNTAX Note that if we use the Bourne shell, there is no need to enter a command in order to set up a variable and assign a value in it. Moreover, make sure you use block capitals when you wish to define global and environment variables. While, small case letters should be used otherwise. 6.4 WRITING AND EXECUTING SIMPLE SCRIPTS Executing single commands is an efficient way to interact with the UNIX operating system. For example, you can get a list of files contained in a directory or get a list of all processes running in the background. Moreover, we can execute programs for text processing and so on. After learning all these basic concepts, we moved forward by understanding the notion of pipes and input/output redirection. However, sometimes so far, we may have thought if there is a way to execute several commands at once. In this section, we will start experimenting with writing simple scripts. Suppose that I wish to execute a command that prints out Hello Ioannis, welcome back. The date today is and so on. First, we need to type PAGE 12

13 my script and save it into a file. At this stage, we can use a text editor such as vi or emacs or we can use cat command and the file output redirections. Then, we need to execute it using the command csh that corresponds to the C Shell process. In this case, csh will act as an interpreter of the given script. In other words, csh will go through the given script line by line and execute every command contained in it. 16 tiger% cat > myhello echo Hello Ioannis... echo Welcome back! echo At this moment, the time and date are date echo Have a nice day experimenting with UNIX! 17 tiger% SAMPLE OUTPUT 6.9: WRITING SIMPLE SCRIPTS In sample output 6.9, we can see that we used car > myhello in order to generate our script. Every input entered went to the file myhello. Then, we invoked the interpreter csh in order to execute the script. The output of the script is described in sample output tiger% csh myhello Hello Ioannis... Welcome back! At this moment, the time and date are Wed May 25 18:09:01 BST 2005 Have a nice day experimenting with UNIX! 18 tiger% SAMPLE OUTPUT 6.10: EXECUTING SIMPLE SCRIPTS Note that in order to execute a script, you can run any shell simply by typing its name. For example, if I am currently running csh and wish to execute it using sh, I need to type sh myhello. Of course, if we would like to we can switch to another shell by typing ksh (Korn) or sh (Bourne). However, if I wish to logout by typing exit, I will be first moved in my default shell and then by typing exit, we can logout from UNIX. Although, we used the interpreter csh in order to execute the previously presented script, there is also another way. The second approach PAGE 13

14 refers to that we can execute the script directly. However, we first need to change its access rights and make it executable. 3 tiger%./myhello./myhello: Permission denied 4 tiger% ls -l myhello -rw svigkoi staff 136 May 25 18:08 myhello 5 tiger% csh myhello Hello Ioannis... Welcome back! At this moment, the time and date are Wed May 25 20:36:29 BST 2005 Have a nice day experimenting with UNIX! 6 tiger% chmod 777 myhello 7 tiger%./myhello Hello Ioannis... Welcome back! At this moment, the time and date are Wed May 25 20:36:45 BST 2005 Have a nice day experimenting with UNIX! 8 tiger% SAMPLE OUTPUT 6.10: EXECUTING SIMPLE SCRIPTS Initially, we attempted to execute our script without changing its access rights. However, the operating system did not allow us to execute this script. We changed, its access rights and the execution of the script was performed successfully. In order to execute our scripts, we also need to enter the prefix./ that denotes our current directory. 6.5 CONTROLLING PROGRAMS In the previous section, we considered the execution of simple scripts. In general when a script is executed more than one processes will be generated. One corresponds to the invocation of the interpreter i.e. csh and the others to commands contained in the script. The interpreter is known as the parent process and any commands incorporated in the script are known as child processes. PAGE 14

15 6.6.1 JOB CONTROL When we execute pipelines or scripts the execution of several commands takes place. For example, if we are going to execute the command cat myhello wc c & by sending it in the background, we are going to get a reference from the shell like [1] This is regular but the process identifier given refers to the second command wc c. Therefore, we need a mean to control the termination of a group of commands. Observe that the reference given by the shell also contains a number in square brackets. In this case, the number is [1]. Therefore, in a similar fashion like terminating single processes, we can use the kill command. In this case we need to type kill %1. The command jobs allows us to display all jobs i.e pipelines or scripts that are currently executing. 40 tiger% csh myshellscript& [1] tiger% jobs [1] + Running csh myshellscript 42 tiger% SAMPLE OUTPUT 6.11: USING JOBS COMMAND jobs command displayed that there is a job running in the background. The job reference number is [1] and its name is csh myshellscript. The cross (+) symbol indicates the default job which refers to the most recently created job. All other jobs are denoted by (-). The default job is known as %%, as well. We can also move processes from the background to the foreground and vice versa. The commands used are known as fg (foreground) and bg (background). As an argument, we use the job identifier prefixed with a %. PAGE 15

16 52 tiger% mailx -s "Experimenting" tom & [1] tiger% jobs [1] + Stopped (tty input) mailx -s Experimenting tom 54 tiger% fg %% mailx -s Experimenting tom (continue) Here is my message to Tom... <Ctrl-D> 53 tiger% SAMPLE OUTPUT 6.12: USING FG AND BG COMMANDS We sent mailx process in the background. We recalled it back by typing fg %% and then we continued working with it by typing an message (content) to Tom EXECUTING JOBS AT A CERTAIN TIME Commands entered in the command prompt are executed almost immediately. However, sometimes we also need to execute commands later as they may require lots of processing power or they are likely to take a long time. We may also schedule the execution of commands for later. The corresponding command is known as at. 62 tiger% at 0330 at> echo It is 3:30 time to wake up! at> <EOT> commands will be executed using /bin/csh job a at Thu May 26 03:30: tiger% SAMPLE OUTPUT 6.12: USING AT Using at, we scheduled the execution of an echo command for 3:30am. The system confirmed that by giving us a notification. This includes which commands will be executed by csh C-Shell and their job number identifier. In this case the job identifier is PAGE 16

17 We can also schedule the execution of several commands, at once. This can be carried out by submitting a file that contains a sequence of commands that should be executed. In this case, we also need to user the option f to indicate that. 64 tiger% at -f mycommands 0330 commands will be executed using /bin/csh job a at Thu May 26 03:30: tiger% ps PID TTY TIME CMD pts/27 0:00 csh 1074 pts/27 0:00 ps 66 tiger% at -l a Thu May 26 03:30: a Thu May 26 03:30: tiger% SAMPLE OUTPUT 6.13: USING AT Similarly, using this option we instructed the system to execute commands included in the file mycommands and we were notified about that. Next, in order to get a list of all scheduled processes, we used the same command with option l. As shown, there are two scheduled jobs at 3:30. The date details entered can have various forms that reflect future time. Although, we provide some, more information can be found in manual pages Noon 06pm August now + 1 month etc. Jobs schedules for future execution are placed in a queue. In order to remove any of them we use the same command with r option that stands for remove. Moreover, we also need to give an argument which is the job number of the job we wish to remove. PAGE 17

18 66 tiger% at -l a Thu May 26 03:30: a Thu May 26 03:30: tiger% at -r a 68 tiger% at -l a Thu May 26 03:30: tiger% SAMPLE OUTPUT 6.14: REMOVING SCHEDULED JOBS Similar to this command is the batch. However, the system decides about the scheduling of a submitted job. Typically, a batch job is schedules by the system according to some principles like the system s workload. 7 tiger% batch < mycommands commands will be executed using /bin/csh job b at Thu May 26 11:40: tiger% SAMPLE OUTPUT 6.14: REMOVING SCHEDULED JOBS We used input redirection in order to schedule the execution of commands that are included in file mycommands. As shown, we were informed by the system that the execution of commands included in mycommands file will take place on Thu May 26 11:40: EXECUTING LARGE PROGRAMS When we need to execute programs that are big in size or they contain algorithms which require lots of computational power, we may need to assign them a low execution priority and send them in the background. This is carried out by: nice <command> & While if a process is already running we can change its priority by using the command renice followed by its process identifier RUNNING PROGRAMS WHILE BEING LOGGED OFF PAGE 18

19 When we are in process of logging out, we may wish to allow some processes running. Moreover, sometimes we are remotely connected through unreliable connections and we might be disconnected without any warnings. In cases such as these, we can use the command: nohup <acommand> & Any standard output and error output will be redirected into a file called nohup.out. Moreover, the use of this command will assign to a command given as argument low execution priority. 6.6 EXERCISES 1. Create a directory called archive. a. Copy some files into this directory. b. Move into this directory and create a directory called dir1. c. From your $HOME copy some files into $HOME/archive/dir1. d. Make sure you are in your $HOME. e. Use pax to create an archive of archive directory with name archive.pax. f. Check its size by using an appropriate command. g. Compress this archive h. Find out the size of the compressed file. i. Remove directory archive and all sub-directories of it. j. Uncompress archive.pax. k. Extract archive.pax l. Check if every file or directory has been restored back. 2. Repeat exercise one and use tar command. 3. Develop a script called lls that has the following functionality: After execution it displays the contents of a directory in a long listing format. Use for execution the: a. csh interpreter b../ notation [Make sure you have changed lls access rights] PAGE 19

20 4. Develop a script that gives as output: Welcome <your log name goes here> Your terminal name is: <terminal name> Today s date is: <DATE> Have a nice day! and execute it using both approaches described in exercise Define a variable called MY_INFO and assign to it a value that corresponds to your name. The scope of this variable should be local. Display its contents on the terminal window. 6. Delete variable MY_INFO. Repeat exercise 5. Give this variable global scope. Change shell and use BOURNE shell. Display its contents on the terminal display. Return back to your C Shell. 7. Write a script that uses variable MY_INFO and its execution displays on the terminal window: Hello <your name> Welcome back! 8. Display the contents of each variable found on page Develop a script called alarm that contains a sleep command with duration 120sec. It also should display that The time is: <time and date> Alarm has been set up <At this point you should put the sleep command> Alarm stopped a. Execute this script in the background. b. Kill this job 10. Execute script developed in exercise 9 and assigned to it a low priority. 11. Execute alarm script again and schedule its execution after an hour. Check the list of all scheduled processes. PAGE 20

21 12. Execute alarm and allow the system to schedule its execution. Then execute it again indicating the system that you wish to execute it while you have to log off. PAGE 21

S E C T I O N O V E R V I E W

S E C T I O N O V E R V I E W AN INTRODUCTION TO SHELLS S E C T I O N O V E R V I E W Continuing from last section, we are going to learn about the following concepts: understanding quotes and escapes; considering the importance of

More information

S E C T I O N O V E R V I E W

S E C T I O N O V E R V I E W INPUT, OUTPUT REDIRECTION, PIPING AND PROCESS CONTROL S E C T I O N O V E R V I E W In this section, we will learn about: input redirection; output redirection; piping; process control; 5.1 INPUT AND OUTPUT

More information

System Programming. Unix Shells

System Programming. Unix Shells Content : Unix shells by Dr. A. Habed School of Computer Science University of Windsor adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introduction 2 Interactive and non-interactive

More information

S E C T I O N O V E R V I E W

S E C T I O N O V E R V I E W FILES AND DIRECTORIES: ADVANCED CONCEPTS S E C T I O N O V E R V I E W In this section, we will learn about: understanding soft (symbolic) links; understanding hard links; working with soft and hard links;

More information

Introduction to UNIX Shell Exercises

Introduction to UNIX Shell Exercises Introduction to UNIX Shell Exercises Determining Your Shell Open a new window or use an existing window for this exercise. Observe your shell prompt - is it a $ or %? What does this tell you? Find out

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Mukesh Pund Principal Scientist, NISCAIR, New Delhi, India History In 1969, a team of developers developed a new operating system called Unix which was written using C Linus Torvalds,

More information

12.1 UNDERSTANDING UNIX SHELL PROGRAMMING LANGUAGE: AN INTRODUCTION Writing a Simple Script Executing a Script

12.1 UNDERSTANDING UNIX SHELL PROGRAMMING LANGUAGE: AN INTRODUCTION Writing a Simple Script Executing a Script 12 Shell Programming This chapter concentrates on shell programming. It explains the capabilities of the shell as an interpretive high-level language. It describes shell programming constructs and particulars.

More information

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02 Essential Unix (and Linux) for the Oracle DBA Revision no.: PPT/2K403/02 Architecture of UNIX Systems 2 UNIX System Structure 3 Operating system interacts directly with Hardware Provides common services

More information

ACS Unix (Winter Term, ) Page 21

ACS Unix (Winter Term, ) Page 21 ACS-294-001 Unix (Winter Term, 2016-2017) Page 21 The Shell From the beginning, Unix was designed so that the shell is an actual program separated from the main part of the operating system. What is a

More information

UNIX shell scripting

UNIX shell scripting UNIX shell scripting EECS 2031 Summer 2014 Przemyslaw Pawluk June 17, 2014 What we will discuss today Introduction Control Structures User Input Homework Table of Contents Introduction Control Structures

More information

Lecture # 2 Introduction to UNIX (Part 2)

Lecture # 2 Introduction to UNIX (Part 2) CS390 UNIX Programming Spring 2009 Page 1 Lecture # 2 Introduction to UNIX (Part 2) UNIX is case sensitive (lowercase, lowercase, lowercase) Logging in (Terminal Method) Two basic techniques: 1. Network

More information

5/20/2007. Touring Essential Programs

5/20/2007. Touring Essential Programs Touring Essential Programs Employing fundamental utilities. Managing input and output. Using special characters in the command-line. Managing user environment. Surveying elements of a functioning system.

More information

Assignment clarifications

Assignment clarifications Assignment clarifications How many errors to print? at most 1 per token. Interpretation of white space in { } treat as a valid extension, involving white space characters. Assignment FAQs have been updated.

More information

The Online Unix Manual

The Online Unix Manual ACS-294-001 Unix (Winter Term, 2018-2019) Page 14 The Online Unix Manual Unix comes with a large, built-in manual that is accessible at any time from your terminal. The Online Manual is a collection of

More information

5/8/2012. Specifying Instructions to the Shell Chapter 8

5/8/2012. Specifying Instructions to the Shell Chapter 8 An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing the functioning of the shell. Employing advanced user features. Specifying Instructions to the Shell Chapter

More information

UNIX Quick Reference

UNIX Quick Reference UNIX Quick Reference This card represents a brief summary of some of the more frequently used UNIX commands that all users should be at least somewhat familiar with. Some commands listed have much more

More information

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal. Warnings 1 First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion. Read the relevant material in Sobell! If

More information

Operating Systems, Unix Files and Commands SEEM

Operating Systems, Unix Files and Commands SEEM Operating Systems, Unix Files and Commands SEEM 3460 1 Major Components of Operating Systems (OS) Process management Resource management CPU Memory Device File system Bootstrapping SEEM 3460 2 Programs

More information

Standard. Shells. tcsh. A shell script is a file that contains shell commands that perform a useful function. It is also known as shell program.

Standard. Shells. tcsh. A shell script is a file that contains shell commands that perform a useful function. It is also known as shell program. SHELLS: The shell is the part of the UNIX that is most visible to the user. It receives and interprets the commands entered by the user. In many respects, this makes it the most important component of

More information

Exploring UNIX: Session 5 (optional)

Exploring UNIX: Session 5 (optional) Exploring UNIX: Session 5 (optional) Job Control UNIX is a multi- tasking operating system, meaning you can be running many programs simultaneously. In this session we will discuss the UNIX commands for

More information

Introduction to Linux

Introduction to Linux Introduction to Linux January 2011 Don Bahls User Consultant (Group Leader) bahls@arsc.edu (907) 450-8674 Overview The shell Common Commands File System Organization Permissions Environment Variables I/O

More information

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute Shells The UNIX Shells How shell works Fetch command Analyze Execute Unix shells Shell Originator System Name Prompt Bourne Shell S. R. Bourne /bin/sh $ Csh Bill Joy /bin/csh % Tcsh Ken Greer /bin/tcsh

More information

I/O and Shell Scripting

I/O and Shell Scripting I/O and Shell Scripting File Descriptors Redirecting Standard Error Shell Scripts Making a Shell Script Executable Specifying Which Shell Will Run a Script Comments in Shell Scripts File Descriptors Resources

More information

Project 1: Implementing a Shell

Project 1: Implementing a Shell Assigned: August 28, 2015, 12:20am Due: September 21, 2015, 11:59:59pm Project 1: Implementing a Shell Purpose The purpose of this project is to familiarize you with the mechanics of process control through

More information

CSC UNIX System, Spring 2015

CSC UNIX System, Spring 2015 CSC 352 - UNIX System, Spring 2015 Study guide for the CSC352 midterm exam (20% of grade). Dr. Dale E. Parson, http://faculty.kutztown.edu/parson We will have a midterm on March 19 on material we have

More information

CHAPTER 3 SHELL PROGRAMS: SCRIPTS

CHAPTER 3 SHELL PROGRAMS: SCRIPTS CHAPTER 3 SHELL PROGRAMS: SCRIPTS Any series of commands may be stored inside a regular text file for later execution. A file that contains shell commands is called a script. Before you can run a script,

More information

Vi & Shell Scripting

Vi & Shell Scripting Vi & Shell Scripting Comp-206 : Introduction to Week 3 Joseph Vybihal Computer Science McGill University Announcements Sina Meraji's office hours Trottier 3rd floor open area Tuesday 1:30 2:30 PM Thursday

More information

Introduction to Linux Organizing Files

Introduction to Linux Organizing Files Introduction to Linux Organizing Files Computational Science and Engineering North Carolina A&T State University Instructor: Dr. K. M. Flurchick Email: kmflurch@ncat.edu Arranging, Organizing, Packing

More information

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p. Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p. 2 Conventions Used in This Book p. 2 Introduction to UNIX p. 5 An Overview

More information

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines Introduction to UNIX Logging in Basic system architecture Getting help Intro to shell (tcsh) Basic UNIX File Maintenance Intro to emacs I/O Redirection Shell scripts Logging in most systems have graphical

More information

The Unix Shell & Shell Scripts

The Unix Shell & Shell Scripts The Unix Shell & Shell Scripts You should do steps 1 to 7 before going to the lab. Use the Linux system you installed in the previous lab. In the lab do step 8, the TA may give you additional exercises

More information

IMPORTANT: Logging Off LOGGING IN

IMPORTANT: Logging Off LOGGING IN These are a few basic Unix commands compiled from Unix web sites, and printed materials. The main purpose is to help a beginner to go around with fewer difficulties. Therefore, I will be adding to this

More information

Oxford University Computing Services. Getting Started with Unix

Oxford University Computing Services. Getting Started with Unix Oxford University Computing Services Getting Started with Unix Unix c3.1/2 Typographical Conventions Listed below are the typographical conventions used in this guide. Names of keys on the keyboard are

More information

Utilities. September 8, 2015

Utilities. September 8, 2015 Utilities September 8, 2015 Useful ideas Listing files and display text and binary files Copy, move, and remove files Search, sort, print, compare files Using pipes Compression and archiving Your fellow

More information

What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell.

What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell. What is the Shell Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell. The shell is your interface to the operating system. It acts

More information

1Z Oracle Linux Fundamentals (Oracle Partner Network) Exam Summary Syllabus Questions

1Z Oracle Linux Fundamentals (Oracle Partner Network) Exam Summary Syllabus Questions 1Z0-409 Oracle Linux Fundamentals (Oracle Partner Network) Exam Summary Syllabus Questions Table of Contents Introduction to 1Z0-409 Exam on Oracle Linux Fundamentals (Oracle Partner Network)... 2 Oracle

More information

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala Linux Training for New Users of Cluster Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala pakala@uga.edu 1 Overview GACRC Linux Operating System Shell, Filesystem, and Common

More information

Linux Command Line Interface. December 27, 2017

Linux Command Line Interface. December 27, 2017 Linux Command Line Interface December 27, 2017 Foreword It is supposed to be a refresher (?!) If you are familiar with UNIX/Linux/MacOS X CLI, this is going to be boring... I will not talk about editors

More information

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion. Warnings 1 First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion. Read the relevant material in Sobell! If

More information

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University Unix/Linux Basics 1 Some basics to remember Everything is case sensitive Eg., you can have two different files of the same name but different case in the same folder Console-driven (same as terminal )

More information

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs; Note: you can find this file under: http://www.cs.queensu.ca/ acmteam/unix.pdf Introduction to Unix Tutorial In this tutorial, you will learn: How to manage your account (user ID, password, shell); Navigating

More information

Bamuengine.com. Chapter 7. The Process

Bamuengine.com. Chapter 7. The Process Chapter 7. The Process Introduction A process is an OS abstraction that enables us to look at files and programs as their time image. This chapter discusses processes, the mechanism of creating a process,

More information

CISC 220 fall 2011, set 1: Linux basics

CISC 220 fall 2011, set 1: Linux basics CISC 220: System-Level Programming instructor: Margaret Lamb e-mail: malamb@cs.queensu.ca office: Goodwin 554 office phone: 533-6059 (internal extension 36059) office hours: Tues/Wed/Thurs 2-3 (this week

More information

Chapter-3. Introduction to Unix: Fundamental Commands

Chapter-3. Introduction to Unix: Fundamental Commands Chapter-3 Introduction to Unix: Fundamental Commands What You Will Learn The fundamental commands of the Unix operating system. Everything told for Unix here is applicable to the Linux operating system

More information

Unix Scripts and Job Scheduling. Overview. Running a Shell Script

Unix Scripts and Job Scheduling. Overview. Running a Shell Script Unix Scripts and Job Scheduling Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Overview Shell Scripts

More information

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell: Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed performs the actions Example:

More information

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs Summer 2010 Department of Computer Science and Engineering York University Toronto June 29, 2010 1 / 36 Table of contents 1 2 3 4 2 / 36 Our goal Our goal is to see how we can use Unix as a tool for developing

More information

MODULE 5. PROCESS AND SYSTEM ADMINISTRATION

MODULE 5. PROCESS AND SYSTEM ADMINISTRATION This document can be downloaded from www.chetanahegde.in with most recent updates. 1 MODULE 5. PROCESS AND SYSTEM ADMINISTRATION 5.1 PROCESS BASICS A process is an instance of a running program. A process

More information

Introduction: What is Unix?

Introduction: What is Unix? Introduction Introduction: What is Unix? An operating system Developed at AT&T Bell Labs in the 1960 s Command Line Interpreter GUIs (Window systems) are now available Introduction: Unix vs. Linux Unix

More information

System Programming. Introduction to Unix

System Programming. Introduction to Unix Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introduction 2 3 Introduction

More information

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers A Big Step Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Copyright 2006 2009 Stewart Weiss What a shell really does Here is the scoop on shells. A shell is a program

More information

9.2 Linux Essentials Exam Objectives

9.2 Linux Essentials Exam Objectives 9.2 Linux Essentials Exam Objectives This chapter will cover the topics for the following Linux Essentials exam objectives: Topic 3: The Power of the Command Line (weight: 10) 3.3: Turning Commands into

More information

CHAPTER 2 THE UNIX SHELLS

CHAPTER 2 THE UNIX SHELLS CHAPTER 2 THE UNIX SHELLS The layers in a UNIX system is shown in the following figure. system call interface library interface user interface Users Standard utility programs (shell, editors, compilers,

More information

Command-line interpreters

Command-line interpreters Command-line interpreters shell Wiki: A command-line interface (CLI) is a means of interaction with a computer program where the user (or client) issues commands to the program in the form of successive

More information

Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX

Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX 15th Jan. 2000 / 3:55 am Part 1: Working with files and rights ------------------------------------- cp

More information

Today. Review. Unix as an OS case study Intro to Shell Scripting. What is an Operating System? What are its goals? How do we evaluate it?

Today. Review. Unix as an OS case study Intro to Shell Scripting. What is an Operating System? What are its goals? How do we evaluate it? Today Unix as an OS case study Intro to Shell Scripting Make sure the computer is in Linux If not, restart, holding down ALT key Login! Posted slides contain material not explicitly covered in class 1

More information

UNIX Tutorial Five

UNIX Tutorial Five UNIX Tutorial Five 5.1 File system security (access rights) In your unixstuff directory, type % ls -l (l for long listing!) You will see that you now get lots of details about the contents of your directory,

More information

NOTE: From the engineering network, users may login directly to the desired computer server using the SSH connection.

NOTE: From the engineering network, users may login directly to the desired computer server using the SSH connection. Overview of MSU Compute Servers The DECS Linux-based compute servers are well suited for programs that are too slow to run on typical desktop computers but do not require the power of supercomputers. The

More information

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

CSC209H Lecture 1. Dan Zingaro. January 7, 2015 CSC209H Lecture 1 Dan Zingaro January 7, 2015 Welcome! Welcome to CSC209 Comments or questions during class? Let me know! Topics: shell and Unix, pipes and filters, C programming, processes, system calls,

More information

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion. Warnings 1 First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion. Read the relevant material in Sobell! If

More information

File system Security (Access Rights)

File system Security (Access Rights) File system Security (Access Rights) In your home directory, type % ls -l (l for long listing!) You will see that you now get lots of details about the contents of your directory, similar to the example

More information

Creating a Shell or Command Interperter Program CSCI411 Lab

Creating a Shell or Command Interperter Program CSCI411 Lab Creating a Shell or Command Interperter Program CSCI411 Lab Adapted from Linux Kernel Projects by Gary Nutt and Operating Systems by Tannenbaum Exercise Goal: You will learn how to write a LINUX shell

More information

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2) BANK ON & SHELL PROGRAMMING-502 (CORE PAPER-2) TOPIC 1: VI-EDITOR MARKS YEAR 1. Explain set command of vi editor 2 2011oct 2. Explain the modes of vi editor. 7 2013mar/ 2013 oct 3. Explain vi editor 5

More information

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Introduction to remote command line Linux. Research Computing Team University of Birmingham Introduction to remote command line Linux Research Computing Team University of Birmingham Linux/UNIX/BSD/OSX/what? v All different v UNIX is the oldest, mostly now commercial only in large environments

More information

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE M2PGER 2013-2014 FORTRAN programming General introduction Virginie DURAND and Jean VIRIEUX 1 Why learning programming??? 2 Why learning programming??? ACQUISITION numerical Recording on magnetic supports

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. NOTE: Text

More information

Self-test Linux/UNIX fundamentals

Self-test Linux/UNIX fundamentals Self-test Linux/UNIX fundamentals Document: e0829test.fm 16 January 2018 ABIS Training & Consulting Diestsevest 32 / 4b B-3000 Leuven Belgium TRAINING & CONSULTING INTRODUCTION TO THE SELF-TEST LINUX/UNIX

More information

Useful Unix Commands Cheat Sheet

Useful Unix Commands Cheat Sheet Useful Unix Commands Cheat Sheet The Chinese University of Hong Kong SIGSC Training (Fall 2016) FILE AND DIRECTORY pwd Return path to current directory. ls List directories and files here. ls dir List

More information

Crash Course in Unix. For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix. -or- Unix in a Nutshell (an O Reilly book).

Crash Course in Unix. For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix. -or- Unix in a Nutshell (an O Reilly book). Crash Course in Unix For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix -or- Unix in a Nutshell (an O Reilly book). 1 Unix Accounts To access a Unix system you need to have

More information

Lab #1 Installing a System Due Friday, September 6, 2002

Lab #1 Installing a System Due Friday, September 6, 2002 Lab #1 Installing a System Due Friday, September 6, 2002 Name: Lab Time: Grade: /10 The Steps of Installing a System Today you will install a software package. Implementing a software system is only part

More information

Computer Systems and Architecture

Computer Systems and Architecture Computer Systems and Architecture Introduction to UNIX Stephen Pauwels University of Antwerp October 2, 2015 Outline What is Unix? Getting started Streams Exercises UNIX Operating system Servers, desktops,

More information

85321, Systems Administration Chapter 6: The shell

85321, Systems Administration Chapter 6: The shell Chapter 6 Introduction The Shell You will hear many people complain that the UNIX operating system is hard to use. They are wrong. What they actually mean to say is that the UNIX command line interface

More information

Shells and Shell Programming

Shells and Shell Programming Shells and Shell Programming 1 Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed

More information

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza Sommario Shell command language Introduction A

More information

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Scripting Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss What a shell

More information

CS 460 Linux Tutorial

CS 460 Linux Tutorial CS 460 Linux Tutorial http://ryanstutorials.net/linuxtutorial/cheatsheet.php # Change directory to your home directory. # Remember, ~ means your home directory cd ~ # Check to see your current working

More information

Operating Systems Lab 1 (Users, Groups, and Security)

Operating Systems Lab 1 (Users, Groups, and Security) Operating Systems Lab 1 (Users, Groups, and Security) Overview This chapter covers the most common commands related to users, groups, and security. It will also discuss topics like account creation/deletion,

More information

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2. File system access rights Linux Tutorial #6 Linux provides file system security using a three- level system of access rights. These special codes control who can read/write/execute every file and directory

More information

Handling Ordinary Files

Handling Ordinary Files Handling Ordinary Files Unit 2 Sahaj Computer Solutions visit : projectsatsahaj.com 1 cat: Displaying and Creating Files cat is one of the most frequently used commands on Unix-like operating systems.

More information

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion. Warnings Linux Commands 1 First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion. Read the relevant material

More information

Shells and Shell Programming

Shells and Shell Programming Shells and Shell Programming Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed

More information

7. Archiving and compressing 7.1 Introduction

7. Archiving and compressing 7.1 Introduction 7. Archiving and compressing 7.1 Introduction In this chapter, we discuss how to manage archive files at the command line. File archiving is used when one or more files need to be transmitted or stored

More information

Computer Systems and Architecture

Computer Systems and Architecture Computer Systems and Architecture Stephen Pauwels Computer Systems Academic Year 2018-2019 Overview of the Semester UNIX Introductie Regular Expressions Scripting Data Representation Integers, Fixed point,

More information

Exploring UNIX: Session 3

Exploring UNIX: Session 3 Exploring UNIX: Session 3 UNIX file system permissions UNIX is a multi user operating system. This means several users can be logged in simultaneously. For obvious reasons UNIX makes sure users cannot

More information

SOFTWARE ARCHITECTURE 3. SHELL

SOFTWARE ARCHITECTURE 3. SHELL 1 SOFTWARE ARCHITECTURE 3. SHELL Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/login.php 2 Software Layer Application Shell Library MIddleware Shell Operating System Hardware

More information

Unix Processes. What is a Process?

Unix Processes. What is a Process? Unix Processes Process -- program in execution shell spawns a process for each command and terminates it when the command completes Many processes all multiplexed to a single processor (or a small number

More information

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo UNIX COMMANDS AND SHELLS UNIX Programming 2015 Fall by Euiseong Seo What is a Shell? A system program that allows a user to execute Shell functions (internal commands) Other programs (external commands)

More information

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University Lecture 4 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation 27-Sep-2017 Location: Goldberg CS Building Time: Wednesday, 16:05

More information

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Esercitazione Introduzione al linguaggio di shell Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza

More information

INSE Lab 1 Introduction to UNIX Fall 2017

INSE Lab 1 Introduction to UNIX Fall 2017 INSE 6130 - Lab 1 Introduction to UNIX Fall 2017 Updated by: Paria Shirani Overview In this lab session, students will learn the basics of UNIX /Linux commands. They will be able to perform the basic operations:

More information

Implementation of a simple shell, xssh

Implementation of a simple shell, xssh Implementation of a simple shell, xssh What is a shell? A process that does command line interpretation Reads a command from standard input (stdin) Executes command corresponding to input line In simple

More information

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc.

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc. Appendix A GLOSSARY SYS-ED/ Computer Education Techniques, Inc. $# Number of arguments passed to a script. $@ Holds the arguments; unlike $* it has the capability for separating the arguments. $* Holds

More information

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples EECS2301 Title Unix/Linux Introduction These slides are based on slides by Prof. Wolfgang Stuerzlinger at York University Warning: These notes are not complete, it is a Skelton that will be modified/add-to

More information

C Shell Tutorial. Section 1

C Shell Tutorial. Section 1 C Shell Tutorial Goals: Section 1 Learn how to write a simple shell script and how to run it. Learn how to use local and global variables. About CSH The Barkley Unix C shell was originally written with

More information

Practical Session 0 Introduction to Linux

Practical Session 0 Introduction to Linux School of Computer Science and Software Engineering Clayton Campus, Monash University CSE2303 and CSE2304 Semester I, 2001 Practical Session 0 Introduction to Linux Novell accounts. Every Monash student

More information

bash, part 3 Chris GauthierDickey

bash, part 3 Chris GauthierDickey bash, part 3 Chris GauthierDickey More redirection As you know, by default we have 3 standard streams: input, output, error How do we redirect more than one stream? This requires an introduction to file

More information

Essentials for Scientific Computing: Bash Shell Scripting Day 3

Essentials for Scientific Computing: Bash Shell Scripting Day 3 Essentials for Scientific Computing: Bash Shell Scripting Day 3 Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Introduction In the previous sessions, you have been using basic commands in the shell. The bash

More information

Linux Shell Scripting. Linux System Administration COMP2018 Summer 2017

Linux Shell Scripting. Linux System Administration COMP2018 Summer 2017 Linux Shell Scripting Linux System Administration COMP2018 Summer 2017 What is Scripting? Commands can be given to a computer by entering them into a command interpreter program, commonly called a shell

More information

Advanced Unix Programming Module 03 Raju Alluri spurthi.com

Advanced Unix Programming Module 03 Raju Alluri spurthi.com Advanced Unix Programming Module 03 Raju Alluri askraju @ spurthi.com Advanced Unix Programming: Module 3 Shells & Shell Programming Environment Variables Writing Simple Shell Programs (shell scripts)

More information

Introduction to UNIX Command Line

Introduction to UNIX Command Line Introduction to UNIX Command Line Files and directories Some useful commands (echo, cat, grep, find, diff, tar) Redirection Pipes Variables Background processes Remote connections (e.g. ssh, curl) Scripts

More information