Common Commands and Their Syntax for the Linux® OS Environment

Common Commands and Their Syntax for the Linux® OS Environment

Filesystem Informational Text Filtering / Mutative bzip2 [opts] [filepattern] ·bzip2 Compression (better) cat [opts] [filepattern] ·Print file contents on STOUT average [opts] [fileargs] ·Print the average of all numbers encountered cd [-] [directory] ·Change directory -E :Display a $ at the end of each line awk [opts] [exp] ·pattern scanning and processing language - :Change to the previous directory you were in -T :Show tabs as ^I -F<fs> :Set the field separator to <fs> chmod [opts] <mode> <filepattern> ·Change permissions -v :Show non-printing characters Ex: cat access_log | awk {‘print $1’} (prints hostnames) -R :Change permissions recursively date [opts] ·Print or set the system date and time Do a ‘man awk’ for more information and examples STRING STRING comm [opts] [file1] [file2] ·Compare two sorted files chown [opts] <user>[.group] <file> ·Change ownership --date= :display time described by STRING STRING -R :Change ownership recursively --set= :set time described by -1 :Suppress lines unique to left file -2 :Suppress lines unique to right file cp opts from to ·Copy files and directories dmesg [opts] ·Print or control the kernel ring buffer [ ] < > < > -3 :Supress lines unique to both files -i :Interactive mode. Prompt before overwriting -c :Clear the contents of the ring buffer csplit [opts] [file] [pattern] ·Split a file on context -p :Preserve file permissions and ownership file [opts] [filepattern] ·Determine the file type prefix prefix -R :Copy directories recursively -z :Try to look inside compressed files -f :Use instead of xx in output filenames -n <digits> :Use <digits> number of digits instead of 2 df [opts] [device name] ·Print filesystem usage info finger [opts] [userpattern] ·Show info about system users -m :Match the exact username specified -z :Remove empty output files -a :Show all filesystems Ex: csplit mailspoolfile "/^From /" {*} -h :Human readable format/Quantify byte information free [opts] ·Display free and used memory in the system cut [opts] [filepattern] ·Remove sections from each line -i :Show inode usage info -b :Display the information in bytes -c range :Output only the characters in range du [opts] [pattern] ·Show space usage on files and dirs hexdump opts ·Show all the characters of a file [ ] Ex: cut –c 1-80 file (truncate lines at 80 characters) -c :Produce a grand total for all arguments -c :Display the input offset in hexidecimal diff [opts] [file1] [file2] ·Differentiate two files -h :Human readable format/Quantify byte information last opts username ·Show last system logins for users [ ] [ ] Ex: diff program-old.c program.c > program.patch -s :Summarize. Only show a total for each argument -num :Show last num of sessions echo [opts] [string] ·Print a line of text find <path> [opts] ·Search for a file -a :Display the hostname in the last column -d :Translates IP numbers to their hostname -e :Enable interpretation of backslashed sequences -f <file> :Use file as last log -n :Don’t automatically insert a newline character Learning find, once and for all! fold [opts] [files] ·Wrap each line to a specified width Find all non-world readable html/htm files and change less [opts] [filepattern] ·View a file a page at a time -i :Do case insensitive searching -s :Break at spaces instead of in the middle of a word. their user ownership to fred using chmod: WIDTH WIDTH -S :Don’t wrap long lines -w < > :Use < > columns rather than 80 find / -type f –name ‘*.html’ -o -name '*.htm' -a +[less commands] :Pass initial commands to less grep [opts] [pattern] [file] ·Print lines matching pattern –perms –644 -exec chown fred {} \; lsof [opts] [names] ·List all open files -B <num> :Print <num> lines of leading context on matches -C <num> :Print <num> lines of trailing context on matches gzip [opts] <filepattern> ·Compress a file or files -E :Interpret pattern as an extended regular expression -1..9 : Set compression level. 9=highest, 1=lowest Try these useful tasks with lsof -i :Do case insensitve matching -d :Decompress file. Same as the gunzip command When the CD-ROM is “busy”: lsof /dev/cdrom -l :Just print the files that match the pattern -v :List the statistics for a compressed file Programs using audio: lsof /dev/dsp -r :Read all files under each directory recursively ln [opts] <tofile> <linkfile> ·Create a sym/hard link -v :Print the lines that don’t match pattern lsof -i 4 -a -s :Create a symbolic link between files (alias name) List open ipv4 network files: head [opts] [file] ·Print the first part of a file -f :Force creation, even if the link file exists -n num :Print the first num lines instead of the first 10 man [opts] [section] <manpage> ·View software manual pages ls [opts] [pattern] ·List file and directory entries numsum [opts] [filepattern] ·Print the sum of a group of numbers -a :View all available manual pages for name Ex: cat numbers.txt | numsum (Add up all numbers in a file) -a :List all files including ones that start with '.' Ex: 'man ls' or 'man -a nice' or 'man 5 crontab' numgrep </numpattern/> [filepattern] ·Print lines matching numpattern -d :List directories themselves, not their contents md5sum [opts] [filepattern] ·Show the uniqueness of files Ex: cat numbers.txt | numgrep /2..100/ (Print numbers from 2 to 100) -l :Long list. Shows permissions and modified time nl [opts] [file] ·Number the lines of a file -r :Recusively list files in directories -c :Check MD5 sums of files against md5sum listfile paste [opts] [files] ·Merge lines of files horizontally -S :Sort output by file size ps [opts] ·Show what processes are running on the system -h :Human readable format/Quantify byte information a :Select all processes on a terminal patch [opts] [patchfile] ·Patch a file using a diff file -X :Sort by filename extension u :Display user oriented format. More columns sed [expression] [file] ·Stream editor -1 :Print output files one per line x :Select processes without a controlling TTY Ex: cat file | sed ‘s/frompattern/topattern/’ > output --time=atime :Show last access timestamp for file w :Show an extra line of process entry per w specified sort [opts] [file] ·Sort lines of text files mkdir [opts] <dirname> ·Make a new directory Ex: ps auxwww =Displays all process information on system -n :Compare according to string numerical value -p :Create parent directories if they don’t exist quota [opts] [user] ·Display disk usage and limits -r :Reverse the result of comparisons -v :Display filesystems where no quota is set mv [-i] <frompattern> <tofile> ·Move/Rename a file split [opts] [file] ·Split a file into pieces random </numpattern/> ·Print out a random number from numpattern -i :Interactive move (Prompt before moving files) -l <num> :Put <num> lines per output file Ex: random /500..1000/ (print a random number between 500 and 1000) opts filepattern ·Remove a file opts file ·Print the last lines of a file rm [ ] < > slocate [opts] [pattern] ·Locate pattern in file index db tail [ ] [ ] -f :Force removal (Don’t ask if it’s ok to remove) -i : Case insensitive search -f :Output appended data as the file grows num> num> -i :Interactive remove (Ask before removing each file) -r : Search the database using POSIX regular expressions -n < :Print last < lines of instead of the last 10 -r :Recusively delete directories an their contents opts file ·Send current output stream to file time [opts] [command] ·Show resource usage for a command tee [ ] [ ] shred [opts] <filepattern> ·Delete file data securely -a :Append to the given file instead of overwriting top [opts] ·Display top CPU processes every X seconds -n :Number of pattern iterations to run (default 25) tr [opts] <set1> [set2] ·Translate char. from set1 to set2 -d sec :Set the delay to sec seconds before refreshing -u :Truncate and remove the file after overwriting Ex: cat index.html | tr A-Z a-z > index-new.html -z :Add a final overwrite with zeros to hide shreding umask [opts] [mode] ·Set the default file permissions uniq [opts] [input] [output] ·Remove duplicate lines tar [opts] [tarfile] [pattern] ·Create an archive -S :Show current symbolic umask -c :Prefix lines with number of occurances uname opts ·Show OS and system information c :Create mode. Create a tar archive [ ] -d :Only print duplicated lines x :Extract mode. Untar archive contents -a :Show everything -u :Only print unique lines t :List mode. List the contents of the archive uptime ·Show system uptime and load -w <n> :Check no more than <n> characters in lines f :Specify a tarfile to use w [opts] [user] ·Show who is logged in/what they are doing wc [opts] [file] ·Print the number of lines in files, etc. v :Verbose mode. Show files being added or untared command ·Locate the related files for a command z,j :De/compress. Send i/o through gzip(z) or bzip2(j) whereis [ ] -m :Print the character count command Show full path to the specified command -l :Print the line count touch [opts] <pattern> ·Update the timestamp on a file which [ ] · who [opts] [args] ·Show who is logged in -w :Print the word count -t :Specify a timestamp to use instead of current time -L :Print the length of the longest line Network Bash Shell Admin ifconfig [devicename] [action] [options] > ·Send STDOUT to a file. overwrite/create a file adduser [opts] <username> ·Add a user to the local system ipchains [opts] ·Manip. ipchains firewall(kernel 2.2+) Ex: ls –l > list-of-files.txt -d <dir> : Set the home directory for the user to dir iptables [opts] ·Manip. iptables firewall(kernel 2.4+) >> ·Send STDOUT to a file, appending to te end of the file -g <group> : Set the primary group for the user to group group

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us