Title: End User and Sysadmin Basics commands
1End User and Sysadmin Basics commands
2Shells
- Shell software providing a user interface
- A shell provides access to services provided by
the kernel related to the term kernel - Two main types of shells
- Graphical
- Command line interface (CLI)
3Shells
- GUI Shells
- KDE
- Gnome
- CLI Shells
- sh, csh, ksh, zsh and tcsh
- bash (GNU) Bourne again shell
- fish Friendly and Interactive Shell
- Windows Shells
- Windows Explorer
- msh Microsoft Shell monad
4Some Bash Features
- Incorporates features from the Korn and C shells
- Command line editing
- Unlimited size command history
- Job Control
- Shell builtins (cd, pwd, alias, echo)
- Some builtins inherited from the Bourne shell
- Some builtins have been added to or improved upon
in bash
5Shell Shortcuts
- match 0 or more characters
- ? match one character
- home directory of current user
- user home directory of user
6Files and directories
- File - an object that contains data.
- Different types of files exist (regular,
directories, links) - Regular files have no restrictions on content
they just contain bits - Inode a data structure containing information
about files (ownership, permissions, type,
timestamps, pointers to data blocks) - The system refers to files not by name but by
inode.
7Files and directories
- Directory an object used to organize files
- A special kind of file that contains a list of
the files it contains - A files name is stored in its parent directory,
not the file itself. - Special directory entries . and .. Can not
be removed
8Files and directories
- Links pointers to another place
- Symbolic links a small file that redirects to
another file - Hard links associating several names with a
single inode. (hard linked files look like two
separate files, but actually point to the same
bits on the disk)
9File system
- Hierarchical
- Types of file systems
- ext2, ext3 (extended file system)
- ReiserFS (was SuSEs default FS)
- FHS Filesystem Hierarchy Standard
- http//en.wikipedia.org/wiki/Filesystem_Hierarchy_
Standard - Special directories Everything is a file
- /dev
- /proc (procfs)
10Users and groups
- User a person who uses a system.
- User account the foundation of security, a
means of identifying users on a system - Group a grouping of users sharing a common need
- Group account method used to group user
accounts on a system
11Permissions
- The ability to control what resources users (or
groups of users) can access. - Different permission paradigms exist
- No permissions DOS, Win9x, MacOS9
- Simple permissions default in UNIX/Linux
- ACLs Windows NT, 2K, XP, 2K3, optional in
UNIX/Linux
12UNIX - Permissions
- Every file is owned by a user
- Every file is assigned a group
- Three permissions classes User Group and
Others UGO - Only an owner and the super user can change
permissions
File Types - Regular file d Directory l
link
Link Count
Other
Modify date
Group
Inode
Owner
Group
Site in bytes
filename
User
File Type
13Getting Help
- man
- info
- --help or h
- tldp the Linux documentation project
- Wikipedia
14Man Page Convention
- Square Brackets and optional
- dot dot dot can be repeated
- Curly braces and Select one value,
separated by - ls OPTION... FILE...
- mkdir OPTION DIRECTORY...
- tail -F -f -r -b number -c number -n
number file ...
15man page sections
- man pages are organized in sections
- Example fstab(5)
16man page navigation
- ???? Scroll man page
- /expression search for expression above
- ?expression search for expression below
- n find next
- q quit
17Your 1st commands
- whoami print effective userid
- whoami OTPTION
- cal displays a calendar
- cal -smjy13 month year
- date print or set the system date and time
- date OPTION FORMAT
18ls list directory contents
- ls OPTION FILE
- Interesting ls options
- -a dont hide hidden files
- -d show directory, not contents
- -h human readable sizes
- -i show inode number
- -l long list
19pwd print name of current/working directory
- pwd OPTION
- Only options are --help and --version
20cd change directory
- A bash builtin
- Allows navigation from working directory to
another - Special options
- . present directory
- .. parent directory
- current users home directory
- username usernames home directory
- - directory flip/flop
21touch change file timestamps
- touch OPTION... FILE...
- Good as a method for creating regular files
- Better as a method for testing to see if you have
permissions to access a given file - -t STAMP option set timestamp to value other
than current time
22mkdir make directories
- mkdir OPTION DIRECTORY...
- Interesting mkdir options
- -v verbose
- -p make parent directories, if they dont
already exist
23rmdir - remove empty directories
- rmdir OPTION... DIRECTORY...
- Interesting mkdir options
- -p try to delete parent directories
- --ignore-fail-on-non-empty suppress errors on
non-empty directories. Will not delete non-empty
directory
24rm - remove files or directories
- rm OPTION... FILE...
- Interesting rm options
- -r recursive removal
- -f force removal, no promts
- rm rf a common method for deleting a directory.
25mv - move (rename) files
- mv OPTION... SOURCE DEST
- mv OPTION... SOURCE... DIRECTORY
- Can be used to move move or rename both files or
a directories - Inodes are preserved
26cp - copy files and directories
- cp OPTION... SOURCE DEST
- cp OPTION... SOURCE... DIRECTORY
- Can be used to copy files and direcories
- Copied files get different inodes
- Interesitng cp options
- -r recursive
- -v verbose
27ln - make links between files
- ln OPTION... TARGET LINK_NAME
- Memory aid ln syntax mirrors cp
- Use full paths!
- -s symbolic or soft links
- Without -s link will be a hard link
28find - search for files in a directory hierarchy
- find path... expression
- The find command is very comprehensive, with a
huge amount of options - Some (of many) interesting options
- -name pattern search for files with a
specific name (note a wildcard needs to be
escaped! i.e. \) - -inum n search for files with a specific
inode number, n
29slocate - Security Enhanced version of the GNU
Locate
- Search for files in a database as opposed to the
actual filsystem - locate is linked to slocoate
- Interesting slocate/locate options
- -u update database, start at /
- -i case insensitive search
30df - report filesystem disk space usage
- df OPTION... FILE...
- Shows disk space available
- Shows where current directory is mounted
- Interesting options
- -h human readable
- -T show type of filesystem
- df alone will show free space on all filesystems
31du - estimate file space usage
- du OPTION... FILE...
- See how much space your files are consuming
- Interesting du options
- -h human readable
- -s summarize (i.e. dont show every file)
32 chown - change file owner and group
- chown OPTION... OWNERGROUP FILE...
- Interesting chown options
- -R recursive
- chgrp can be used alternatively
33chmod - change file access permissions
- chmod OPTION... MODE,MODE... FILE...
- Examples
- chmod ux,gw,gw foo
- chmod 644 foo
- Octal notation shortcut
34Homework
- Check out the FHS http//www.pathname.com/fhs/
- Check out the Bash Reference Manual
http//www.gnu.org/software/bash/manual/bashref.ht
ml