UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
Published byModified over 5 years ago
Presentation on theme: "UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat."— Presentation transcript:
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat
Logging On and Logging Off Unix is a multitasks, multiusers, and interactive operating system. Unix allow people to share the same computer by logging on to it from terminals or consoles. Three general categories to connect to a UNIX system Local Area Network connection. Internet connection. Stand Alone connection.
Before trying to log in to any UNIX system in any way, you need to identify yourself as a valid user to the system. You can identify yourself to a UNIX system by typing in a valid username (log-in name) and a valid password for that username. In this chapter we will discuss 2 ways to login to a UNIX system using computers running windows system. In this course we will use the University Main Frame computer which runs a UNIX system (ip : 10.0.0.14, hostname : orchid.just.edu.jo) Logging On and Logging Off (cont … )
Connecting via PuTTY To connect to a UNIX system using this way you have to have the following A computer running a Windows operating system You computer is connected to a LAN or to the Internet You have downloaded and installed the PuTTY program. See the site http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html You know the host name or the IP address of the UNIX computer you want to connect to. You have a username and a password that will allow you to login to the UNIX computer.
Connecting via PuTTY (cont … ) Run the PuTTY program. you will see the following window Type the hostname or the ip address of the UNIX computer. Change the protocal to Telnet. Press the open button.
Connecting via PuTTY (cont … ) You will se the following window Enter your username. Enter your password. While entering the password you will not see the characters of your password on the screen for security reasons. You can then start running commands.
Connecting via Telnet To connect to a UNIX system using this way you have to have the following A computer running a Windows operating system You computer is connected to a LAN or to the Internet You know the host name or the IP address of the UNIX computer you want to connect to. You have a username and a password that will allow you to login to the UNIX computer.
Connecting via Telnet (cont … ) From start menu click RUN, you will see the following. Type telnet and then the hostname or the ip address of the UNIX computer. Press the Ok button.
Connecting via Telnet (cont … ) You will se the following window Enter your username. Enter your password. While entering your password you will not see the characters of the password on the screen for security reasons. You can then start running commands.
Loging-out You can disconnect yourself from the unix using one of the following commands exit
The Structure of a UNIX Command $ command [[-]option(s)] [option argument(s)] [command argument(s)] $ is the shell prompt. Command is the name of the UNIX command [-option(s)] is one or more modifiers that change the behavior of the command. [option argument(s)] is one or more modifiers that change the behavior of the [-option(s)]. [command argument(s)] is one or more objects that are affected by the command.
The Structure of a UNIX Command (cont … ) You must use space to separates commands, options, option arguments, and command arguments, but no space is necessary between multiple options or multiple option arguments. The order of multiple options is irrelevant. A space character is optional between the option and the option argument. Always press the key to submit the command for interpretation and execution.
Command Examples ls ls –la ls –la m* lpr –Pspr –n 3 proposal.ps
File and Directory Structure When you first login, you are working in the home directory. Home directory is a folder that is associated with the username and password you used to login. The directory you are presently in is known as the current working directory. There is only one current working directory active at any given time.
Changing User Password passwd is the UNIX command for changing the user password. $ passwd Changing password for cis1. Old password: New password: Retype new password: Hashed database not in use, only /etc/passwd text file updated. $
Viewing the Contents of Files using cat You can display the complete contents of one or more files on screen by using the cat command. cat[options][file-list] Concatenate/display the files in file-list on standard output. Options are: -e display $ at the end of each line -n put line numbers with the displayed lines.
CAT Examples $cat student_records [ contents of file displayed] cat exam1 exam2 [ contents of exam1 and exam2] When cat command is executed without arguments, it takes input from the keyboard. $cat This is a test. This is a test.
Creating Files Using cat cat > myfile The previous command will create a file on the current working directory named as myfile allowing you to input any text you wont. To finish the input, use the.
Viewing Files One Page at a time more[option][file list] To concatenate/display the files in file-list on standard output one screen at a time. Options: +/str start at the first line containing str. -nN display N lines per screen/page +N start displaying the contents of the file at line number N.
MORE Examples $ more sample [ contents of sample one page at a time] $ more sample letter memo [ contents of sample, letter, and memo] $ more -n20 sample [ contents of sample 20 lines per page] $more +/include test.c [ contents of test.c file in the current directory starting from the first line containing the string include]
Copying Files The UNIX command for copying files is cp. cp[options] file1 file2 will copy file1 to file2 if file2 is a directory, make a copy of file1 in this directory. Options -i if destination exist, prompt before overwriting. -r recursively copy files and subdirectories.
Moving Files The operation move in UNIX may result in simply renaming a file if it is on the same directory. If the source and destination are on different directory, the move operation results in a physical copy of the source file to the destination, followed by removal of the source file. mv [options] file1 file2 mv [options] file-list directory The first will move file1 to file2 or rename file1 as file2. The second will move all files in file_list to directory. Options -i prompt the user before overwriting the destination.
Removing/deleting Files The UNIX command for removing (deleting) files is rm. rm[options] file list To remove files in file list from the file structure. Options -i prompt the user before removing the files in file_list. -r recursively remove the files in the directory which is passed as an argument. You want to be sure that you want to do so before using this option.
The ls command ls[option][pathname-list] to send the names of the files in the directories and files specified in pathname list to the display screen. Options are the following -F display `/` after directories, * after binaries, and @ after symbolic. -a display name of all the files including the hidden files. -i display inode number. -l display long list that includes access permissions, link count, owner, group, file size.
Creating Directories To create a directory use the command mkdir[options] dirnames options -m modes, create a directory with the given access permission ( permissions in chapter 8) -p create parent directories that do not exist in the pathnames specified in dirname.
Removing Directories To remove an empty directory us the command Rmdir[options] dirname Option -p to remove empty parent directory as well.
Accessing Directories You can access a directory using the command cd directoryName To return to the parent of the active directory use the command cd.. To return to the home directory use the command cd To display the full name of the current working directory ( active directory) use the command pwd
Getting Help With Commands To get a detailed help about one or more of the UNIX commands and their options, go to the UNIX reference manual pages. The syntax of the command is as the following $ man cmdName [cmdName] … $ man -k keyword [keyword] … To get short description of what any particular UNIX command does you can use the command whatis as the following: $ whatis cmdName [cmdName] …
Searching You can search for a file using the command whereis [options] filename Optoins -b Search only for binaries -s Search only for source code
Viewing personal information whoami, tells you who is currently logged on to a terminal. $ whoami cis1 $ To see more details about the user who is currently log in to a terminal, type the command who am i as follows $ who am i cis1 pts/4 Mar 3 08:40 (172.18.10.22) $
Viewing hostname hostname command displays the name of the host computer you have logged into. $hostname orchid.just.edu.jo $
Current log-in users The who command, will tell you who are log-in right now. $ who jlp tty0 sep 20 10:05 you tty2 sep 22 10:34
Printing Files Two command to print files in UNIX systems. On System V UNIX the command lp is used to print a file and lpr command is used on System BSD UNIX. With the lpr command, you need the option –P to specify the printer name to print on and –n option to determine the number of copies to be printed. lpr -P spr sample lpr -P spr –n 3 sample With the lp command, the option –d is used to specify the printer name to print on and –n option to determine the number of copies to be printed. lp -d spr sample lp -d spr –n 3 sample
Calendar and Date The command cal is used to display the calendar of a specified month in a specified year. cal [month][year] The date command will display current date and time as follows. $date sun sep 20 11:23:01 EET 2001
Communication commands Write command is used to write on a user terminal or terminals. The command can take two parameters, the first is the user name that you want to write on his terminals. The second is the terminal name you want to write on – it is optional. You can use the mesg command to disaple the appearance of the real-time one way message on your terminal. mesg y, permits others to use write or talk commands with you. mesg n, prevents others to use write or talk commands with you. mesg displays the current status of the mesg.
Creating Aliases alias command is used to create a nickname for a command as follows. alias [name] [string] The name parameter states the new name (alias) of a command. The string parameter states the command you want to create an alias for it. The alias command without any parameters will list all the aliases in your system. To cancel an alias use the command unalias with the alias name. To cancel all the aliases use the command unalias with the option -a.