Unix Useful Snippets

THL Toolbox > Developers' Zone

Unix Useful Snippets

These are super basic to anyone who knows Unix. However as I know barely enough to do damage, I will accumulate a hopefully ever-increasing set of tricks here.

Navigating files and directories and finding out what's there

To log in as a particular user to a particular server

  • ssh dln4n@blue.unix.virginia.edu (where dln4n is the user and stuff on the other side of the "@" are the server)

Navigate to desired directory

  • cd /net/quandu/thdl-mms/batch-processing/contemporary-art-images

List the files

  • ls -a: Lists the files and folders in the current working directory
  • ls -l: Lists the files and folders in the current working directory, with permissions
  • ls -a -R | more: Gives a list of all the files in the current directory as well as all the subdirectories. "since this is likely to be a long listing, it's 'piped' into *more* so the display pauses at the end of each screen."

Print the files in a directory and sub-directories

  • ls -a -R > files.txt: this will print a list of the files into a new text file. It would be good to add an other part about printing it to a directory on one's local computer.

Outputting a file of the files in a directory and its subdirectories to home on an osx mac. Prints the directory structure, modified date, and other stuff. (Thanks, Travis!)

  • find . -ls -name *.* | awk '{print $8" "$9" "$10"t"$11" "$12" "$13" "$14" "$15" "$16}' > ~/files.txt

Useful links

Provided for unrestricted use by the external link: Tibetan and Himalayan Library