Fairly generic reference: https://www.tjhsst.edu/~dhyatt/superap/unixcmd.html

  1. ls, for listing all files in a directory.
    1. ls -a | list all files
    2. ls lol* | list all files with name starting with lol
    3. ls -d lol* | list all files AND directories with name starting with lol
    4. ls -l | list files in long format
    5. ls -r | list in reverse order
  2. cd for changing directory
  3. rm for removal
    1. rm -f | remove a file forcefully (ignore non-existent files, and do not prompt before deleting)
    2. rm -i | remove a file, prompt before removal.
    3. rm -r | remove directories and their content recursively.
    4. rm -v | remove verbosely – listing all the paths that were removed.
  4. mv for move/rename
    1. mv source (multiple) dest | move files/directories from source to destination
    2. mv source target | rename file/directory from source to target; if target file already existed, it would be overwritten.
    3. mv -i | prompt before overwriting
    4. mv -f | no prompt before overwriting
    5. mv -u | overwrite only when source is newer than destination.
    6. mv -v | verbose
  5. more for looking at a file, one page at a time
  6. grep [option] pattern(regex) file
    1. grep -b | display line number in original file for each line
    2. grep -c | display number of matched lines in each file
    3. grep -l | display only the names of matching files
    4. grep -w | match whole word

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s