Malcolm 'Max' DeRungs

Linux console



l show in long format
l a all directories (including dots)

l h show unit suffixes

l t sort by time modified
l t r reverse time sort order
l S sort by size
l S r reverse size sort order

ls -lat
ls -latr

l d list directories as plain files

Good for limiting the scope of a wildcard search to the current directory
ls -lahd *dev*


Zip and unzip different files and directories as a Text ARchive file using different compression methods.

c create
x extract
z gzip compress
v verbosely
f to file
C to a non-current directory
u update

.tar no compression
.tar.gz gzip compression
.tar.bz2 bzip2 compression


Create tarchive from source directory
.tar -cvf filename.tar source_directory/
.tar -cvzf filename.tar.gz source_directory/
.tar -cvjf filename.bz2 source_directory/

Trailing slash on source directory is essential for tarchiving Solr schemas on a Mac

tar -czvf myhiwayschema.tar.gz myhiwayschema/


List all files in tarchive
tar -tvf filename.tar /source_file_directory


Extract file into current working directory as folder called "filename"
tar -xvf filename.tar
tar -xvzf filename.tar.gz
tar -xvjf filename.bz2

Extract file into some other already created directory
tar -xvf filename.tar -C /other/directory/

Don't overwrite or replace
tar -xvkf filename.tar

Extract specific file(s)
tar -xvf filename.tar filename_1 filename_2


Securely copy a file between hosts

scp thisfilehere.png user@there:thatfilethere.png

More than one file

scp this*.png user@there:thatdirectorythere


scp -r thisdirectoryhere user@there:thatdirectorythere

Either direction

scp -r thisdirectoryhere user@there:thatdirectorythere
scp -r user@there:thatdirectorythere thisdirectoryhere

To a specific host port

scp -r -P 44444 /Users/myname/Desktop/this.png