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
cd *directory*
List the contents of a directory
ls *directory*

List the contents of a directory, with permissions and file size
ls -lha *directory*
Remove Directory and all files inside (recursive forced)
rm -rf *directory*
Tar – compress a folder
tar -czv -f *location_of_compressed_file*.tgz *files_to_compress*
Tar – compress a folder, with exclusions
tar -czv -f *file_or_directory* --exclude="file.html"
Tar – compress a folder, with Grouped exclusions
tar -czv -f *file_or_directory* --exclude="file*.html"

– will remove file1.html, file-long-name.html, etc.

Tar – decompress a tarball
tar -xzvf ** *./location/to/decompress*
SCP – Pull a file from another server (Remote-to-Remote or Remote-to-Local)
scp *[email protected]:path/to/* ./

Note: ./ means current directory.

Show details about a file
more *filename.php*
Edit a file
nano *filename.css*

Leave a Reply

Your email address will not be published. Required fields are marked *