Professional Documents
Culture Documents
Home › content
Topic
SSH: It's really not that scary Design (11)
by Megan McDermott, 29 October 2009 - 12:50am Graphics (2)
For a long time, I avoided using ssh. As a designer, I thought it would be too complicated and difficult to learn. CSS (14)
As it turns out, I was wrong! For the most part, ssh (and the shell commands needed to perform tasks) isn't that HTML (16)
difficult to do. Being able to use SSH will make it easier and faster for you to perform many common tasks on Drupal (6)
your web server. Even if you're on a shared hosting account, you may be able to access your website using SSH
Programming (5)
(check with your hosting provider to find out).
Server management (1)
Warning
Discussion topics
Always be careful when running shell commands. Make sure you understand what your command is doing
and double check to make sure your syntax is correct. If you are copying commands provided on a Webmaster's Corner
website or forum, it is important that you understand what the command is doing. Incorrect or malicious Web Design and Graphics
commands could erase your entire website or otherwise compromise your server.
HTML, CSS, and Javascript
More information on malicious commands. Web Programming and
Application Development
Web Database Development
Getting started: logging in Web Hosting and Domain
Using a terminal on Linux or Mac Names
Server Management
1. open a terminal
Promotion and Marketing
2. type ssh username@yourwebsite.com (probably the same hostname, username & password you use to
ftp) Search Engine Challenges
3. enter your password at the prompt Online Business and
eCommerce
Using PuTTY in Windows Website Critique Area
Shortcuts
● use the u p a r r o w to cycle through recently used commands
● use m a n [ c o m m a n d ] to view the manual for that command (e.g. man ls). Press q to leave the manual.
● use c t r l + C to escape a command
Navigating around
Two commands are needed to view and navigate folder structures on your site. The ls (or li list) command shows
you the files and folders in a directory. cd (or c hange d irectory) command lets you move beteween folders. To
find out where you are, use pwd (short for p rint w orking d irectory). This will show you the current directory path.
Once you become familiar with your web server's structure, you will get very fast at navigating. This is often more
convenient than using a GUI-based FTP client or file manager that requires you to click to open directories.
When you first log in to your server you may be directed straight to your website folders or you may end up in a
folder for your user account. It might take some navigating around to figure out how to get toGenerated by www.PDFonFly.com
your website files. at 5/24/2010 5:21:23 AM
URL: http://www.apaddedcell.com/ssh-its-really-not-scary
Often going to /var/www or /www will get you where you need to be.
Sample commands
ls
list files in a directory
ls -l
long format list - shows permissions, file owners (individual and group), file sizes, and last modified dates
ls -a
shows all files (including hidden files, such as .htaccess)
ls -la
shows long format and all files at once
cd folder
navigate to the directory folder
cd folder1/folder2
navigate to the directory folder2 which is located inside folder1
cd ../
move up one level
cd ../../
move up two levels
cd ../../folder
go up two levels and navigate to the directory folder
cd /
go back to the site root
pwd
show current path
Shortcut
When enteirng a file path, press tab to auto-complete.
A sample ls command
A sample ls -l command
file
prints the file type and some additional information about the file (varies depending on the file type)
cat
prints the contents of the file
more
prints the contents of the file on one screen (useful for longer files); press enter to scroll through the file and q
to return to the prompt.
less
an enhanced version of more with additional shortcuts. Use the up and down arrows to scroll.
head
prints the first 10 lines (by default) of the file
tail
prints the last 10 lines (by default) of the file
Sample commands
cat style.css
prints the entire contents of the file style.css
cat -n style.css
prints the contents of style.css with line numbers
head -20 style.css
prints the first 20 lines of style.css
mv
move
cp
copy
rm
remove
These three commands are structured the same way and take the same options.
Common options
-r
recursive (includes all sub-files and folders)
-f
force (supresses any warnings or prompts) Generated by www.PDFonFly.com at 5/24/2010 5:21:23 AM
URL: http://www.apaddedcell.com/ssh-its-really-not-scary
-v
lists files as they are being processed
Shortcut
* is a wildcard. When used alone it represents all files in the directory. When included with other text it
represents any number of additional characters.
Sample commands
mv file.html ../
moves file.html up one level
mv file.html folder/file.html
moves file.html into folder
mv file.html file2.html
moves file.html to file2.html (effectively renames the file)
mv * folder/
moves all files in the current directory into folder
cp file1.html file2.html
copies file1.html to file2.html
cp * ../
copies folder contents up one level
cp -r * ../
copies folder contents up one level recursively (includes all sub-files and folders)
rm -rf *
removes all files and folders, including sub-folders, and suppress all prompts
touch
creates a new file, or updates timestamps on existing file
mkdir
creates a new directory
Sample commands
touch file.html
creates a new file called file.html
mkdir folder
creates a new folder called folder
1. Navigate to the directory where your CMS or plugin/module resides. Depending on your hosting setup the
command will look something like this:
cd httpdocs/wp-content/plugins/ (for wordpress plugins)
2. Get the URL for the plugin or module you want to download (you should be able to right-click on the
download link and copy the link address).
3. Download the plugin to your server using the wget command:
wget http://example.com.com/theplugin.zip
If you're ugrading more than one plugin or module at once, you can separate them with spaces, like this
Depending on where the files extract to, you may need to move them around to overwrite the existing versions.
Generated by www.PDFonFly.com at 5/24/2010 5:21:23 AM
URL: http://www.apaddedcell.com/ssh-its-really-not-scary
Discussion
To discuss, ask questions or comment on this article please see the Webmaster Forums discussion on SSH: It's
really not that scary.
What's next?
Stay tuned for the next article in this series on managing file permissions using CHMOD. Further articles will cover
more advanced command line utilities.
Resources
● List of Unix utilities
● Guide to Linux File Command
● Malicious commands (information and examples)
aPaddedCell © Copyright 2006-2007 InterMedia. Site and all articles (unless otherwise specified) licensed under a Creative Commons License.