Date post: | 06-May-2015 |
Category: |
Technology |
Upload: | utkarsh-sengar |
View: | 2,284 times |
Download: | 3 times |
Linux User Group @ SJSULinux Commands
(Find PocMan on lug-sjsu.org)
Linux User Group at San Jose State University 2
BASH – Bourne Again Shell
• What is a Shell?
• Customizing the environment
- Local and Environment variablesHOME, SHELL, PS1PATH, LD_LIBRARY_PATH
- Aliasesalias ll=‘ls –l’
- Command historyhistory, !!, !#
- Initialization Scripts.bashrc file
Linux User Group at San Jose State University 3
BASH contd.
• Redirecting • standard input <• standard output >• standard error 2>
• Pipes |
• Command Substitution `` • Wild-Cards
* ? [ijk] [!ijk] [x-z]
Linux User Group at San Jose State University 4
Basic File System commands
• cd – Changing the current directory
• ls – Listing directory contents
• mkdir – Making directories
• rmdir – Removing directories
• pwd – Checking current directory
Linux User Group at San Jose State University 5
Basic File commands
• cat – Displaying file contents
• cp – Copying a file
• mv – Renaming files
• rm – Removing files
• file – Knowing the file types
• Soft and Hard links
Linux User Group at San Jose State University 6
Backing up files
• gzip - Compressing Files
• gunzip - Decompressing Files
• tar – Archival program
Linux User Group at San Jose State University 7
Basic File Attributes
• Listing file attributes `ls -l`
• File Ownership
• File Permissions
• Directory Permissions
• chmod – Changing File ownership
Linux User Group at San Jose State University 8
The Process
• Basics process commands
ps, pstree, top
• Process states
‘ctrl z’ – suspend a process
‘ctrl c’ - kill a process
• Runnning Jobs in Background
'&' , bg, fg
• kill - Killing Processes with Signals
Linux User Group at San Jose State University 9
Networking commands/tools
• Checking the network
ping, traceroute, ifconfig, netstat
• DNS
host, nslookup, dig
• Remote Login
telnet, ssh
Linux User Group at San Jose State University 10
Miscellaneous commands
• man & info
• who, whoami
• touch
• finger, finger <username>
• whereis, which
• df, du
• shutdown
Linux User Group at San Jose State University 11
Vi
vi filename [count][command]
(count repeats the effect of the command)
Vi starts in command mode. The positioning commands operate only while vi is in command mode. You switch vi to input mode by entering any one of several vi input commands. Once in input mode, any character you type is taken to be text and is added to the file. You cannot execute any commands until you exit input mode. To exit input mode, press the escape (Esc) key.
grep
What Is grep?Grep is a tool that originated from the UNIX world during
the 1970's. It can search through files and folders (directories in UNIX) and check which lines in those files match a given regular expression. Grep will output the filenames and the line numbers or the actual lines that matched the regular expression. All in all a very useful tool for locating information stored anywhere on your computer, even (or especially) if you do not really know where to look.
grep contd..
• grep -i – ignores case• grep -A Num– prints Num lines after context• grep -B Num– prints Num lines before context• grep -C Num – prints Num lines around
context
Grep contd..
• grep -c – returns count of matching lines• grep -H – return filenames in which match is
found.• grep -d type – searching in directories. Where
type can be one of the following– skip (skip directories specified)– recurse (iterate into directories search each file in
the directory)– read (read directories)
Grep contd..
• Regular Expressions– [ ] - range of characters– * - matches zero or more times– + - matches one or more times– ^ - beginning of line– $ - end of line– ? - match is optional and matches at most once– {n} – matches n occurrence
Cut
To extract information from section from each line of input (usually files)
Extraction can be done based on• -b – bytes• -c – characters• -f – fields• -d – delimiter (default is tab)
Cut contd..
A range must be provided in order to extract informations.
• -N – to end of line• -M – from beginning of line till M
Usually N and M are counted from 1 (not 0). If we specify 0, latest version errors out but previous versions assumes it to be 1.
03/09/10Linux User Group at San Jose State University
By
Rohit Surve and Harish Krishnan