Introduction To Linux: Lei Zhang UCLA Linux Users Group
Introduction To Linux: Lei Zhang UCLA Linux Users Group
What is Linux?
UNIX-like Operating System Developed by Finnish computer science student Linus Torvalds as an OS project in 1991. Made available on the net and has been developed ever since
Users in Linux
Every User has: username, group(s), password, home directory Root User vs Regular User
Root == Administrator == God
Use sparingly, only when necessary Remember, it's your bed, don't Sh** in it
Regular Users
Limited privileges
Path
Used to search for commands Colon separated e.g. /usr/bin:/bin:/usr/X11R6/bin
Structure of fs
The fs is conceptualised as a tree / is the root directory and everything is a subdirectory of it branching downwards Other drives are attached to the tree
No C drive Attach other filesystem using the mount and umount command
umount is the unmount command, not a typo Normally only root can (un)mount
Tree Structure
root directory / essential user programs /bin kernels and boot loader /boot device files /dev configuration files /etc home directories /home essential libraries and kernel modules /lib mount point for other filesystems /mnt addon (optional) software /opt system internals /proc the root user's home directory /root essential system binaries /sbin temporary files /tmp user programs (not as essential) /usr /usr/bin | similar hierachy to root dir /usr/lib /usr/sbin various other files (logs, mail, etc) /var
Types of files
Everything is a file! Ordinary files - text, data or programs Directories - contain other files/directories Links - pointers to other files Special files
Devices - represent hardware (e.g. /dev/fd0) Others - pipes, sockets
The GUI
X Window System
underlying graphics system
Useful Apps
Konsole runs a shell (the CLI) OpenOffice wordprocessor/spreadsheet Mozilla Web Browser Gaim AIM / MSN / Yahoo IM client
ls output
Permissions links owner owners group size of file/dir date of last modification name of file/dir
Permissions
Multi-user OS needs access mechanism for files Each file/dir has permissions for its owner, its owners group and everyone else on the system (u,g,o) The permissions are for the ability to read, write and execute a file/dir
RWX
Output of ls -l if permission is on a letter appears if it is off there will be a minus sign (-) first one is - for a file or d for dir next 3 are the users perms next 3 are the groups perms last 3 are everyone else's perms
Examples of permissions
-rw-r--r-dr-xr-xr-x -rwxr-xr-lrwxrwxrwx foo bar prog.c prog
Changing permissions
Chmod command - has 2 modes
number (convert bits to decimal number)
directly set the permission read = 4, write = 2, execute = 1 e.g. 750 is equivalent to rwxr-x---
Navigation
Absolute - full pathnames (/) Relative - pathnames relative to were you are in the fs (. .. ~) Shortcuts
. is current directory .. is the parent of current directory
~ is your home directory
Filename completion - type first few characters of a file/command and press tab, the shell will fill in the rest
Basic commands
cd change directory
e.g. cd /usr/bin
cp copy files
e.g. cp ~/cs111/source.c /mnt/floppy
mv move files
e.g. mv /tmp/mystuff/* ../somewhere
rm remove files
e.g. rm ee115c/hwk*
Standard input/output
3 special file handles for input/output of programs
standard input (stdin) file handle 0 standard output (stdout) - file handle 1 standard error (stderr) - file handle 2
Pipes
The pipe character is: | The output of the command on the left of the pipe becomes the input to the command on the right
ls | wc -l output of ls as input to wc
Processes
ps command lists processes on the system
e.g. ps auwx shows all processes running on the system at the time
Compiling Programs
gcc GNU C Compiler Simple compiler usage
gcc o hello hello.c
Compile only
gcc c hello.c gcc c functions.c
Network Utils
ping - tells if a machine is on the network
e.g. ping www.ucla.edu will keep sending packets until CTRL + C
traceroute - shows all points between machine and machine you are looking for
e.g. traceroute www.yahoo.com shows all the hops to yahoo
The End
(For Now)