Web Hosting Talk







View Full Version : SSH Newbie Guide


Joseph_M
02-23-2004, 08:19 AM
This Guide Isn't By Any Means Complete, But Contains A Number Of Commonly Used Commands In SSH. Please Note That Anything In BOLD Is A Description, And Anything In Italic Is The Actual Command!

File Manipulation
ls -l ---- This Will List All Files/Directories In Your Current Directory
ls -al ---- Lists All Files & Information
ls –alR ---- Lists All Files & Information In All SubDirectories
cd ---- Changes Directory
clear ---- Clears The Screen
cp [oldfilepath] [newfilepath] ---- Copies File From A Directory->Another
rm [filepath] ---- Removes A File
rm * ---- Removes All Files In A Directory
mkdir [dirname] ---- Creates A New Directory
mv [oldfilepath] [newfilepath] ---- Moves A File/Directory


Compression
unzip [filepath.zip]----Unzips A .ZIP File
tar -xvf [filepath.tar]----Untars A .TAR File
gzip -d [filepath.gz]----Ungzips A .GZIP File
gzip -d filepath.tar.gz----Ungziptar's A .TAR.GZ File
tar -xvf filepath.tar


Permissions
0 = --- No Permission
1 = --X Execute-Only
2 = -W- Write-Only
3 = -WX Write & Execute
4 = R-- Read-Only
5 = R-X Read & Execute
6 = RW- Read & Write
7 = RWX Read, Write & Execute

You Need To Set This On Files For
Owner - The File Owner
Group - People On The Server
User - Everyone

Its normally best if you want to keep a file really secure, to keep Group as "0" to stop people on the server from looking/changing it!


System Information Commands

du----Shows Disk Usage
netstat----This Tells You Who Is Connected To The Server + Hostname
netstat -n----This Tells You Who Is Connected To The + IP
kill----Kill A System Process
top----Gives You System Information (e.g. Processes, RAM usage etc)
ps----Shows Currently Running Processes
ps U [username]----Shows Currently Running Processes By A User
last----Tells You The Last User To Login

uzaymerkezi
04-30-2004, 03:38 AM
really good i was hardly looking for these codes as newbie :)

stftk
05-18-2004, 03:03 PM
Nice guide but you may want to add a few things:

- how to extract a .tar.bz2 file to the compression section.

tar -xvjf filename.tar.bz2

- how to create a symbolic link.

ln -s old new

- how to download a file from a remote server

wget http://domain/file

- how to reboot the server

reboot

- how to edit a file

vi filename
pico filename

CybexHost
05-21-2004, 10:33 AM
This is basically what you need to know to get started and rolling out the door. Great job Joseph_M, very well organized and arranged!

<<< Signature removed >>>

RofyHost
05-21-2004, 11:31 AM
Thanks Joseph_M {Tells All!},

you are really telling all :)
much appreciated!

basic
05-22-2004, 12:32 AM
Some more I often use:

- delete all files AND subdirectories
/bin/rm -rf <directory-name>

- copy folders
cp -r

- show ownership and permissions of files in your location
ls -l

Adrian_M
05-24-2004, 09:44 PM
Not to nitpick,.... but; These aren't really SSH commands.

SSH is just what is being used to remotely connect to a server.

I think these commands would more acurately be described as general UNIX ( or Linux, FreeBSD, *NIX, etc.) shell commands.

Joseph_M
05-26-2004, 08:10 PM
Adrian, as they're for Newbies this is what they'd look for, anyway, I posted exactly what was asked for by (I believe) Mouse.

coolbuddy
06-01-2004, 04:03 AM
Hey Joseph_M,

Definately a nice informative post ..!
I am sure many people who are new to SSH will be able to use it with the help of your stuff...

Joseph_M
06-05-2004, 07:11 PM
As long as its helped someone, I'm happy!

gilbert
06-05-2004, 08:21 PM
Originally posted by Joseph_M
As long as its helped someone, I'm happy!
:cool: i second that :)

SSH-Raj
06-05-2004, 09:01 PM
wow a thread all about me! :D

leight
06-09-2004, 12:03 PM
some quick notes:

ls -l ---- This Will List All Files/Directories In Your Current Directory
ls -al ---- Lists All Files & Information

-l will not list all files, -l is just for (l)ong info line
the -a is for (a)ll, and lists hidden directories and files, (names preceded with a . )

Also useful:

ps -x - show your background processes.
du -sh <dir> shows a human readable summary for the size of a directory.

<cmd> | grep <string> - this will parse all of the output from <cmd> and show only the lines that contain <string>, very useful for machines with lots of processes when you only want to find one. ie: ps -ax | grep named ... this would show the process entry for the dns server.

You have permissions listed but, not the copmmand to change them: chmod <perms> file

Also useful is chown user:group file to change the ownership of a file.

Just a couple of things I think are important, also dont forget that godsend command, "man"

CArmstrong
06-14-2004, 11:46 PM
To add onto leight's post above, man keyword invokes the manual pages for the keyword. It can be a program, utility, or something else entirely. Give it a shot before you ask a question :)

openXS
07-22-2004, 09:08 AM
Isnt quite useful since it doesnt say how to read a file.

For the first time I bought a server and I got an email from the provider asking me to get the pass from a txt via SSH located in some folder. Using the above commands I managed to get IN, but as I was'nt able to open the file, I had to pay them and wait a day to get it done..heh

Hostom [Kirill]
07-29-2004, 11:15 PM
As busy as you may be playing with your server, don't forget to secure SSH by allowing SSH2 only and no direct root logins ( /etc/ssh/sshd_config is your friend ) ;)

kyro_02
06-26-2005, 07:04 PM
They're helpful for me, as i'm a newbie.

But, What you didn't say is how to kill a process... How do I go about killing a ./hlds or a ./bnc bnc.conf process/programme...i've deleted all the ./bnc bnc.conf folder and files by accident...well sorta...but ./bnc is still running. please help >:|

Thanks.

kyro_02
06-26-2005, 07:22 PM
Actually, silly me I didn't see it in the list the first time I looked - there now :)

edit:

How do I delete users & user folders in SSH?

Thanks.

edi2: Also, this is pretty much STUPID but i've created like 4 user accounts and all can view everything in the ]IPADDRESS - theirusername - theirpassword] ftp client folders etc.. for shell... any ideas? where can I do to force them to only view THEIR OWN /theirusername/ folder?

- also, although they can view everything (from root and all - they cannot copy/del/edit or anything to the files, but I still want to for extra security make them only viewable to their own user folder eg: /nathan/ (in shell ftp)

aldee
07-10-2005, 02:01 PM
> How do I delete users & user folders in SSH?

rm -rf foldername
deluser username

> Thanks.

> edi2: Also, this is pretty much STUPID but i've created like 4 user
> accounts and all can view everything in the ]IPADDRESS -
> theirusername - theirpassword] ftp client folders etc.. for shell... any
> ideas? where can I do to force them to only view THEIR OWN
> /theirusername/ folder?

Set permissions correctly. 1705 should be fine if your users are all in the same group. If the directory does not have to be accessible through the web, 700 should be sufficient.

> - also, although they can view everything (from root and all - they
> cannot copy/del/edit or anything to the files, but I still want to for
> extra security make them only viewable to their own user folder eg:
> /nathan/ (in shell ftp)

You better do. Otherwhise they can easily spy out passwords from scripts etc. Are you sure you want to be running an unmanaged server, leave alone giving anyone but yourself access?

kyro_02
07-10-2005, 10:45 PM
All I wanted to give each user is only access to their FTP - I tried those commands and they worked good, they can go into the the /home/ folder - but cannot see anything at all) - they can view their folder O.K - thanks.

pycoder
08-26-2005, 08:00 PM
Very nice collection of basic commands. Should do the average beginner a lot of good :)

BaselineAce
08-27-2005, 01:21 PM
I've been looking for something like this. Thank you.