Richard Castera

Application Developer/Designer
  • Home
  • About
  • Projects

Using SSH and Unix commands

Having some basic knowledge of SSH and Unix commands is very useful. Developed in 1995, SSH (Secure Shell) was created as a secure alternative to Telnet. Telnet is a protocol allowing for command line access to a Unix, Linux or FreeBSD based remote computer. I’ve listed some basic commands to get you familiar with them.

The cd command is used to move to a specific directory.
Command: cd
Format: cd /directory/to/browse
The cp command will copy the file or folder from the source, to the destination.
Command: cp
Format: cp /directory/source /directory/destination
mkdir creates a directory.
Command: mkdir
Format: mkdir /directory_to_create
The rmdir command deletes a directory.
Command: rmdir
Format: rmdir /directory/to/delete
The rm command deletes a file.
Command: rm -f
Format: rm -f filename
The mv command will rename or move a file stated in the first portion to the name or location stated in the second portion.
Command: mv
Format: mv /directory/you/want/to/rename/or/move /new/directory/name/or/location
This command will tar zip the files in the directory specified in the second portion into a tar file specified in the first portion.
Command: tar cvf
Format: tar cvf filename.tar.gz /directory/you/wish/to/archive
The tar -xvf will extract all files from the tarball specified into the directory you are currently in.
Command: tar -xvf
Format: tar -xvf filename.tar.gz
This will create a zip file, with the name specified in the first portion from the file or directory listed in the second portion.
Command: zip
Format: zip filename.zip /file/or/folder/you/want/to/zip
This command will unzip or un pack the named zip file, into the directory you’re currently in.
Command: unzip
Format: unzip filename.zip
The Ls command lists files, and folders within the directory you specify
Command: ls
Format: ls /directory/you/wish/to/list/files/
This will add a forward slash to the directory names within the directory you specify
Command: ls -f
Format: ls -f /directory/you/wish/to/list/files/
This will show “hidden” files in the directory you specify
Command: ls -a
Format: ls -a /directory/you/wish/to/list/files/
This command shows detailed info about each file in the directory you specify.
Command: ls -l
Format: ls -l /directory/you/wish/to/list/files/

Also, a lightweight, freeware application which supports SSH commands that I use is, PuTTY.

Don't forget to Subscribe and Follow!

Be sure to subscribe to the feed and follow me on Twitter for more insights and resources!

7 Responses to “Using SSH and Unix commands”

  1. Comment #1 - Permalink
    Doug
    08/01/2009

    Great post! Bookmarking this one!

  2. Comment #2 - Permalink
    Strap
    08/02/2009

    Hi,
    my two cents in your post:
    - cp: to copy also directories you must use the -r attribute, otherwise you get an error.
    - mkdir: a tip… if you use -p attribute you can create all the tree ;)
    - rmdir: remove an empty directory… if you want to remove a not empty directory you’ll use the rm -Rf /path/to/remove.
    - Ls is a ‘typing error’… i think :)

    I hope you find my comment useful :)

    Cheers
    Strap

  3. Comment #3 - Permalink
    Richard
    08/02/2009

    @Strap, Thanks for your comment! ls is actually correct. It Lists the contents of a directory.

  4. Comment #4 - Permalink
    Kim H
    08/25/2009

    Wow, huge thanks! I’m still learning some Unix/terminal commands to get a better functionality out of my mac; I’m somewhat familiar with cp and cd as I’ve used them, but this is definitely getting a bookmark.

    Putty is nice too; I used it while I was still on Windows.

  5. Comment #5 - Permalink
    Brady
    09/28/2009

    WOW! What a great list. Thank you so much. This is extremely helpful.

  6. Comment #6 - Permalink
    Richard
    10/03/2009

    @Brady Thanks!

  7. Comment #7 - Permalink
    Carl
    06/04/2010

    Very good post! It will be helpful with the configuring I do of Ubuntu boxes for clients!

    Question though….I have some boxes that when I remotely run the ls -al command through SSH that return blank information. I have to log into the boxes to check the status of updates. All the boxes happen to be Ubuntu 8.10. Is there something in SSH and it’s key that may be causing it?

It's Your turn

Click here to cancel reply.
You

CAPTCHA Image
CAPTCHA Audio
Refresh Image



About The Author

Richard is a Web Developer currently working for SankyNet. He is available for freelance work. Visit Shifting Ideas for inquiries. Thanks!
  • Premium Email Templates

    Social Profiles

  • Twitter
  • Facebook
  • LinkedIn
  • Digg
  • Google
  • GitHub

    Last Tweet

  • Beware the heat-seeking Nerf machine-gun coming to a cubicle near you http://om.ly/svHF #fb
  • Follow me
  • Archives

    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • September 2008
    • August 2008
    • July 2008
    • June 2008
  • Categories

    • AJAX
    • Apache
    • Books
    • Drupal
    • Ecommerce
    • Flash
    • Google
    • Javascript
    • jQuery
    • Magento
    • Marketing
    • Mootools
    • My Thoughts
    • MySQL
    • News
    • Photoshop
    • PHP
    • Prototype
    • SEO
    • Web Resources
    • Wordpress
  • My Favorites

    • 37 Signals
    • Andrew Warner
    • Chris Coyier
    • Chris Shiflett
    • Collis Ta'eed
    • Development Seed
    • Drupal
    • HubSpot
    • James Padolsey
    • Joel On Software
    • John Resig
    • jQuery
    • Kevin Rose
    • Life Hacker
    • Magento
    • Mashable
    • Matt Cutts
    • Matt Ryan
    • MySQL
    • NetTuts
    • Noupe
    • Photoshop Tutorials
    • PHP
    • Smashing Magazine
    • Tech Crunch
    • WoorkUp
    • Wordpress

2010 © Copyright. Richard Castera - All Rights Reserved.

Top