Presentation on theme: "Jump to first page Unix Commands Monica Stoica Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision."— Presentation transcript:
Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision of American Telephone and Telegraph Company. n Unix system has two kinds of software: u the operating system software u the application software like pico, pine, emacs, etc. n Some of the functions of the Unix operating system are: u it provides a filing system (write, copy, rename, move files) u it provides for the loading and executing of the user programs u it provides a communication link between the computer and its accessories (input-output devices as terminals, printers, disks, etc).
Jump to first page Additional Features of the Unix System n Multi-user time-sharing u several people at different terminals can use the computer at the same time. n Multitasking u one user runs several computing jobs simultaneously
Jump to first page Unix Shell n The Unix shell is a command line interpreter, or a program that forms a link between users and the computer. n The shell accepts commands that you type into the computer, and then it executes them. n The shell contains over 100 built-in commands for your use. At the shell % prompt you can type your commands. n There are 2 widely used shells: u Bourne shell provided with the standard Bell Labs version of Unix u C shell developed at the University of California, Berkeley
Jump to first page Changing the prompt set prompt=“Any message you want ” n If you got tired of the (login) % prompt, you can type set prompt=“Any message you want ” and every time you come back to the shell prompt your message will show up instead of the (login) %. n Unix will reset this back to (login)% when you logout. n Make sure you leave a space between the end of your message and the ending “.
Jump to first page TIPS Ctrl-h. It will erase one typed character every time you press it. n In case the backspace key does not work when you try to erase something at the Unix prompt, try pressing simultaneously Ctrl-h. It will erase one typed character every time you press it. NOT !. n Do NOT put spaces, capital letters or unusual characters (as !) in file names. man command n For more information on a command type man command.
Jump to first page Password passwd n If you want to change your password, type passwd at the (login) % prompt. You will be prompted to enter your old password, the new password, and to retype the new password. n You should have at least one digit in your password. n When you choose your new password remember that Unix is case-sensitive and even a space is considered a character.
Jump to first page Finding the time, date and calendar of any year date n If you type date at the (login) % prompt, you will get the date of the current day, the day of the week, and the current time. cal year n If you type cal 03 1776 at the shell prompt, you will get the calendar of the March, 1776. If you do not enter a month (that is, you type only cal year) you will get all twelve months of that year. n Tips: u you can type cal month year of your birth and find out what day of the week you were born! u the year should be in the range 0-9999 AD.
Jump to first page who The who command n Since Unix is a time-sharing system, several people can use the system at the same time. who n By typing who you will get a list with all the people logged in at that moment. The leftmost column shows the terminal at which the person is working, the next column shows the date and the rightmost column shows the computer number (IP number). who am I n If you type who am I you will get information about yourself. You can also use this command in case somebody forgot to logout of unix and you want to know who that person was. who > turkey cat turkey n Typing who > turkey will create a file called turkey and write on it all the information listed as a result of the who command. You can type cat turkey to view the file.
Jump to first page The finger command finger option argument n General form: finger option argument n finger command without an argument n finger command without an argument gives the same result as who command, but also gives the full name of each person. It also gives the idle time in minutes since the person last gave a Unix command. -m finger -m smonica n Adding the option -m obligates finger to look only for those people who’s login names match the argument name. For example finger -m smonica will search for only the people who’s login name is smonica. -l -s n Option -l forces finger to give the results in long format, and the option -s to give it in short format.
Jump to first page finger More on finger command finger -s johnfinger -l john It will search for all the people who’s first name, last name or login is john. n If you want to find out all the people with the name or login john who have an account in Unix, type finger -s john or finger -l john depending on whether you want a short form or along form. It will search for all the people who’s first name, last name or login is john.
Jump to first page Sending e-mail fast without opening pine mail login n At the (login) % prompt type mail login (the login of the person you want to send an email). Press Enter. Subject: here type your subject n Then type Subject: here type your subject. Press Enter and type the message you want to send. Ctrl-d n When you are done type Enter and then Ctrl-d, and you should get a (login)% prompt.
Jump to first page Files and Directories /root n While working with files and directories it will help if you think about Unix as a big tree. All directories in Unix stem from /, also called root. course n One of root branches is called course for students’ directories. All users’ home directories stem from course. n On the next pages you’ll learn how to create directories and files, move or copy files from one directory to another, and much more.
Jump to first page The ls command ls option argument n General form: ls option argument. Some of the options are: u -c lists by last change u -l lists in long format, giving links, owner, size in bytes, and time of last file change ls -l directoryname n typing ls -l directoryname will list all files and subdirectories of that directory in long format. ls n Typing only ls will give the current working directory.
Jump to first page The ls command n The information on the leftmost part shows the permissions of read, write and execute on each listing. d - n If the first character is a d, it means that is a directory. A hyphen - indicates a file. n The next three characters show the permissions of the owner on that file or directory, the next three the permissions of the group the owner belongs to, and the last three characters show the permissions of the rest of the world on that file or directory.
Jump to first page Example of an ls command result n This is an example of an ls command result: n -rwxr-xr-- n The first hyphen - shows that this is a file rwx n the next three letters rwx show that the owner has read, write and execute permission on that file, r-x n the next group of three r-x show that the group the owner belongs to has only read and execute permission r-- n the last three r-- show that the rest of the world has only read permission on that file.
Jump to first page The cat command cat argument n general form: cat argument n The cat command is used to concatenate and display files. Concatenate means to link together. cat file2 n Typing cat file2 will display on the screen file2 assuming that this file2 already exists. n You can use cat > newfile to create a new file and to enter text into it. n You can use cat file2 file3 >> file4 to append file2 and file3 to the end of the file4. If file4 does not exist, it is created now to receive the input from file2 and file3.
Jump to first page The wc word count command wc option argument n General form: wc option argument wc file2 n example: wc file2 will list from left to right the number of lines, words, and characters of file2. n options: u -w counts only words in a file u -c counts only characters in a file u -l counts only lines in a file
Jump to first page Copy Command cp option argument n General form1: cp option argument n cp file1 file2 n cp file1 file2 creates a copy of file1 and gives it the name file2. If a file named file2 already exists, it will be replaced by the new one. n Options: u -i protects you from overwriting an existing file by asking you for yes or no before it copies a file with an existing name. u -r can be used to copy directories and all their contents into a new directory cp file1 file2 directory n General form 2: cp file1 file2 directory u this copies the list of the files given into the directory which must already exist. The originals are kept in place.
Jump to first page The Move Command n The mv command lets you change the name of a file or directory and lets you move a file from one directory to another. n mv file1 to file2 mv directory1 directory2 n mv file1 to file2 will change the name of file1 to file2. The file itself is unchanged. If a file named file2 already existed, it will be replaced by the content of file1. Same thing applies for directories (mv directory1 directory2). -i n Option -i: it will ask you before it copies to a file with an existing name. mv file1 file2 directory n You can move files to an existing directory by typing: mv file1 file2 directory
Jump to first page Differences between cp and mv n The cp command creates a new file with a new ID number and with its own link (name) to a directory. The old file continues to exists. n The mv command creates new names for the existing files and dumps the old names. It does not create a new file.
Jump to first page The rm command rm file n If you want to remove a file, type rm file n Once that you removed it, it’s gone for good. n This is the end of the presentation!