SSH COMMANDS

these are the ssh commands that are being used in Linux and Unix systems

man [COMMAND] ----- information of a command

cd [FOLDER_NAME] ----- moves to a directory
cd .. ----- move 1 up
cd ~ ----- moves to the home directory
cd - ----- moves to the previous directory
cd /----- moves to the root directory

ls ----- list of all files
ls -a ----- list of all files including the hidden files
ls -l ----- list of all files with details
ls *.[FILE_EXTENSION] ----- list of all files with that file extension
ls -d */ ----- list all directories

mkdir [FOLDER_NAME] ----- creating a folder
rm -rf [FOLDER_NAME] ----- deleting a folder
rmdir [FOLDER_NAME] ----- deleting a folder
rm [FILENAME] ----- deleting a file
rm * ----- deleting all files in the directory
rm *.[FILE_EXTENSION] ----- delete all files with that file extension

mv [OLD.FILENAME] [NEW.FILENAME] ----- renaming a file
mv [FILENAME] [FOLDER_NAME_1]/[FOLDER_NAME_2] ----- moving a file to a folder
mv [FILENAME] ..\ ----- moving a file, one directory up (..\ denotes one directory)

cp [FILENAME_1] [FILENAME_2] ----- creates a copy of a file
cp [FILENAME] [FOLDER_NAME] ----- creates a copy of a file to a folder


touch [FILENAME.FILE_EXTENSION] ----- creates a file

whereis [FILENAME] ----- search for a folder

date ----- to display the time and date of the server

pwd ----- shows the full path of the directory

df ----- displays the hard drive partition

quota ----- displays the quota

whoami ----- displays the username

who ----- displays who are connected to the server

clear ----- clears the screen

exit ----- log-off the shell

wc [FILENAME] ----- count the number of lines
wc -l [FILENAME]

wget [WEBSITE_PATH.FILE_EXTENSION] ----- downloads a file

lynx [DOMAIN_NAME] ----- view a website

dig [DOMAIN_NAME] ----- displays the nameservers

host [DOMAIN_NAME] ----- displays the mailservers

whois [DOMAIN_NAME] ----- displays the whois info of a domain

nslookup [DOMAIN_NAME] ----- displays the IP Address of the domain

ping [DOMAIN_NAME] ----- ping the server of the domain

nc -v [DOMAIN_NAME] 80 ----- checks if port 80 (web) is accessible

nc -v [DOMAIN_NAME] 21 ----- checks if port 80 (ftp) is accessible

ps -x ----- displays the processes that a user is current running

sysinstall ----- sytem install, install packages(ports)

netstat -na |grep LISTEN

► installation process:
1.) ./configure
2.) make
3.) make install

► file transfer protocol (ftp):
1. ftp [DOMAIN_NAME]
2. enter the ftp username
3. press Enter
4. enter the password
5. the prompt wil change to ftp>
6. put [FILENAME] ----- uploads a file to the remote diretory
get [FILENAME] ----- download to local
mput [*.FILE_EXTENSION] ----- uploads multiple files with that file extension

► file permissions:
chmod [###] [FILENAME] ----- change file permission
-rwxrwxrwx
-[owner][group][other]

r - read = 4
w - write = 2
x - execute = 1

0 = --- No permission
1 = --x Execute only
2 = -w- Write only
3 = -wx Write and execute
4 = r-- Read only
5 = r-x Read and execute
6 = rw- Read and write
7 = rwx Read, write and execute

► editor:
vi [FILENAME] ----- opens the editor
pico / nano [FILENAME]

:w ------ saving wihout exiting the editor
:x ------ save and exit
:wq [filename] ------- save-as and exit
:q! ---- exit and disregard changes
:/[word] ----- search for a word in a file

more [FILENAME] ----- shows the content of a file; toggle down
less [FILENAME] ----- shows the content of a file; toggle up and down
cat [FILENAME] ----- shows the content of a file; show all


tail –f [FILENAME] ----- displays the last part of a file
tail –n [N] [FILENAME] ----- displays the last N-lines of a file

► unzipping a file:
unzip [FILENAME].zip
tar -xvf [FILENAME].tar
gzip -d [FILENAME].gz
gunzip [FILENAME].gz

for [FILENAME].tar.gz:
tar -zxpf [FILENAME].tar.gz
1. gzip -d [FILENAME].tar.gz
2. tar -xvf [FILENAME].tar

► zipping a file:
zip [FILENAME].zip [FILENAME_1].[FILE_EXTENSION] [FILENAME_2].[FILE_EXTENSION]

zip -r [FILENAME].zip [FOLDER_NAME]

► search:
grep [WORD] * ----- searches for a WORD in a file within the directory
and displays the filename with the line containing that WORD;
case sensitive

grep -i [WORD] * ----- case insensitive

► mysql database:

import
mysql -h [HOSTNAME] -u [DB_USERNAME] -p [DB_NAME] < filename.sql

export
mysqldump -h [HOSTNAME] -u [DB_USERNAME] -p [DB_NAME] > filename.sql

►installing mutt:
$> wget ftp://ftp.mutt.org/mutt/mutt-1.4.2.3.tar.gz
$> tar -zxvf mutt-1.4.2.3.tar.gz
$> mv mutt-1.4.2.3 mutt
$> ./configure
$> make
$> make install

► apache:
vi /etc/rc.conf ----- configuration file
add this line to enable apache: apache22_enable="YES"

1. enable apache: vi apache22
2. run: /usr/.../apache22 start
3. run: /usr/.../apache22 restart

► miscellaneous:

freedns ----- 208.67.222.222

cd /usr/local/etc/rc.d -- folder for startup script

cd /usr/share/bin/ -- program files

cd /usr/share/examples --

cvsup5.freebsd.org ----- http://www.freebsd.org/doc/en/books/handbook/cvsup.html

to access server through ssh:
1. install sudo
2. access user
3. access sudo

_________________________________________________________________
  .  cdo bloggers   .  my digital corner   .  sacha chua   .  the oatmeal   .  toxel.com   . 
  .  Hotels & Resorts Worldwide   .