Download presentation
Presentation is loading. Please wait.
Published byStephanie Webster Modified over 9 years ago
1
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles
2
Where to Start Available UNIX: mars, neptune, juniper, …in CSULA campus You have to have an account first through submitting an application (Library). Login name + Password Use telnet to login. There are several different kind of telnet. You also can install Linux at home (if dual boot, windows first).
3
Telnet C>telnet mars.calstatela.edu C>telnet neptune.calstatela.edu, … Start Run telnet mars.calstatela.edu Program SSH Secure Shell Secure Shell Client. MochaSoft Telnet ………..
4
The Shell Shells provide the command line interface to UNIX (there are other types of interface) Why learn the command line? The GUI isn't always available The command line is often more efficient The command line is often more powerful You must become familiar with using the command line
5
Introduction to UNIX Commands Command line format is command_name [ -switches ] [ parameter1 ] [ parameter2..] There must be whitespace between each of these components command_name the name of command to be executed (will match an executable file somewhere) switches switches or options are used to modify the operation of a command. parameter1 a list of parameters/arguments which will be passed to the command
6
Introduction to UNIX Commands Examples include ls ls -l ls -l /etc /home ls -ld /etc /home
7
The File Hierarchy UNIX uses an upside down tree of directories for file storage. For the Windows users: Files are documents, Directories are Folders
8
The File Hierarchy A file is a container for data, be it an image, text, a word processor file. A directory is a collection of files. To UNIX a directory is just a file that contains pointers to files. We will use file/directory interchangably Each user has a home directory in which they can do what they want.
9
Paths Paths or path names are specifications of where to find a file/directory. There are two types of paths absolute (full) The path to the file is fully specified /home/….. relative The path to the directory is relative to the current directory (The pwd command will tell you the current directory)../…
10
Paths Directory and filenames are separated by / (can't be used in filenames) Every directory contains at least two directories. the current directory.. the parent directory Try ls -al in any directory. Example neptune> ls -al total 1848 drwx--S--- 10 jguo 1024 Apr 23 12:02. drwxr-sr-x 227 root 4096 Apr 7 10:26.. -rw------- 1 jguo 500 Dec 16 22:05.Xauthority -rw------- 1 jguo 221 Apr 17 12:29.bash_history -rw------- 1 jguo 2205 Nov 13 2002.cshrc
11
Important Directories /bin binaries required when in single user mode /bin /dev device files /dev /etc System configuration files and scripts /etc /home User home directories /home /lib Main OS shared libraries and kernel modules /lib /sbin System administration binaries and tools /sbin /tmp Storage of temporary files /tmp /usr Contains almost everything else including libraries, binaries, applications and packages /usr /var Variable data, usually machine specific. Including spool directories for mail and news. Also system logs and messages. /var
12
Moving around the file hierarchy cd command is used to change directories Examples cd Return to the home directory of the user. Can also use ~ as your home directory (at least in bash) cd / Return to the root directory. cd.. Change to the parent directory. cd. Change to the current directory. cd../../../bin Move to the bin directory which is up three directories
13
Commands are programs UNIX commands are actually executable programs stored on the disk. This means you can write commands too! The shell reads the command line you typed extracts out the name of the command looks for a file with a matching filename creates a new process using the code in that file Common commands are stored in the bin directories: /bin /usr/bin /usr/local/bin /usr/X11R6/bin /sbin /usr/sbin There are around hundreds commands. If you see the error message dir: command not found This means that the shell was unable to find the executable file with a name which matches the name of the command.
14
Help We can't show you how to use all hundreds commands. However, most of these commands have online documentation in the form of manual pages. Manual (man) pages are a reference to individual commands. They can be difficult to read (take your time). As with any manual, the manual pages are divided into sections
15
Help Manual Section Description 1 User commands 2 System calls 3 Library functions 4 Special files 5 File formats 6 Games
16
What are the man pages They are text files written using a special format. (one file for each man page)text files Stored in subdirectories of the man directories (/usr/man /usr/local/man) Written by people to provide assistance with commands Displayed using the man command Examples man ls man convert man man
17
Some Commands date Display the current time and date who display who is currently on the computer gcc/g++ C++/C compilers cal display a calendar wc count the number of characters, words and lines cat display the contents of a file more and less display the contents of a file a page at a time
18
Some Commands rm Remove a file cp Make a copy of a file mv Move a file or change the name of a file file Display the information of a file grep Search for a specific string in a file whereis Display the path of a utility program Which Display the path of a command finger Display detail information about users echo Display a line of text on the terminal Mail Send and receive emails write, talk, mesg Communicate each other
19
vi vi is an editor. It is the editor I strongly suggest you start using since you will be a professional software engineer. Why? it's always available on UNIX it makes you look like professional it is hugely powerful
20
Introduction to vi vi is a modal editor (two mode) command mode The initial mode where most of the keys perform vi commands insert mode The mode where what you type is inserted into your document command line mode Transitions command mode to insert mode Several commands/keys put you into insert mode i a I A o O insert mode to command mode Hit the escape key
21
vi Commands 23x Delete 23 characters 25dd Delete 25 lines d$ Delete from current position to the end of the line
22
vi Command Line Commands :wq Write any changes and quit :q Quit (will only do so if no changes) :q! Quit without saving changes http://www.eng.hawaii.edu/Tutor/vi.html
23
PICO pico is a full screen editor. It is easy to learn and easy to use.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.