SSH Reference Sheet – Basic

SSH Reference Sheet – basic Secure-shell commands for every day use!

The more I work with SSH, the more I love it! Unfortunately, half the time I forget the commands. This is the first of a series of “Reference Sheets” to help myself and others learn/remember SSH commands.

Note: Anything surrounded by *asterisks* is where your input is required.

Change Directory

{code}cd *directory*{/code}

List the contents of a directory

{code}ls *directory*{/code}

List the contents of a directory, with permissions and file size

{code}ls -lha *directory*{/code}

Remove Directory and all files inside (recursive forced)

{code}rm -rf *directory*{/code}

Tar – compress a folder

{code}tar -czv -f *location_of_compressed_file*.tgz *files_to_compress*{/code}

Tar – compress a folder, with exclusions

{code}tar -czv -f *file_or_directory* –exclude=”file.html”{/code}

Tar – compress a folder, with Grouped exclusions

{code}tar -czv -f *file_or_directory* –exclude=”file*.html”{/code}
– will remove file1.html, file-long-name.html, etc.

Tar – decompress a tarball

{code}tar -xzvf ** *./location/to/decompress*{/code}

SCP – Pull a file from another server (Remote-to-Remote or Remote-to-Local)

{code}scp *[email protected]:path/to/* ./{/code}
Note: ./ means current directory.

Show details about a file

{code}more *filename.php*{/code}

Edit a file

{code}nano *filename.css*{/code}