SSH commands wiki

Home/ Support/ Info/ SSH Commands

SSH commands Putty / SSH / Unix / Linux

For Windows you can use putty. You can free download putty and connect for your server via SSH

File commands

ls – list files

ls -al – full list file info

cd dir – сhange dir

cd – change dit to home dir

pwd – current dir

mkdir dir – make dir

rm file – delete file

rm -r dir – delete dir

rm -f file – force delete file

rm -rf dir – force delete directory dir *

cp file1 file2 – copy file1 in file2

cp -r dir1 dir2 – copy dir1 in dir2 and make dir2, if dir2 not exist

mv file1 file2 – move file1 в file2. if file2 is a dir moving file1 into directory file2

ln -s file lin – make symbol link into file

touch file – make the file

cat > file – make std out into file

more file – print file

head file – print 10 first lines from file

tail file – print 10 last lines from file

tail -f file – print file up while last 10 lines

Process control

ps ax – print current process

top – print all process

kill pid – kill process id pid

killall proc – kill all process name proc *

bg – list stopped and background task; continue execution of a stopped job in background

fg – brings to the foreground the last task

fg n – to make the task n to the foreground

Permisson on files

chmod octal file – to change rights of file to octal, separately for user, group and for all by adding:

  • 4 – read (r)
  • 2 – write (w)
  • 1– execute (x)

Examples:

chmod 0777 – read, write, execute for all

chmod 0755 – rwx for owner, rx for groups and other.

Additional options: man chmod.

SSH

ssh user@host – connect to host as user

ssh -p port user@host – connect to host on port port as user

ssh-copy-id user@host – add your key into host for user to enable login without password and keys

FIND

grep pattern files – find pattern in files

grep -r pattern dir – find pattern recursive in dir

command | grep pattern – find pattern in command dump; example: ps ax| grep apache2

locate file – find  all files with name 'file'

find [/path] -name "filename.ext" – find all files with name filename.ext. You can use mask, example:  "*file?"

System info

date – current date and time

cal – calendar of current month

uptime – current uptime

w – who is online?

whoami – your name in system

finger user – system info about user

uname -a – cureent kernel

cat /proc/cpuinfo – info about CPU

cat /proc/meminfo – info about RAM

man command – help manual about command

df – disk free info

du – disk used  file space usage

free – user RAM and swap

whereis app – path to app

which app – default app program

Archives

tar cf file.tar files – create tar-archive with file.tar name include files

tar xf file.tar – extract file.tar

tar czf file.tar.gz files – create tar with packed Gzip

tar xzf file.tar.gz – extract tar with Gzip

tar cjf file.tar.bz2 – create  tar-archive with packed Bzip2

tar xjf file.tar.bz2 – extract tar whith Bzip2

gzip file – move and archive file and rename in file.gz

gzip -d file.gz – extract file.gz in file

Network

ping host – echo from host

whois domain – get whois info about domain

dig domain – get DNS information about domain

dig -x host – find host

wget file – download file

wget -c file – continue downoad

Install packages

Install from sources:

./configure

make

make install

dpkg -i pkg_name.deb – install package  *.deb (Debian, Ubuntu)

rpm -Uvh pkg_name.rpm – install package *.rpm (CentOs, Fedora)

Клавиатурные сочетания

Ctrl+C – break current command

Ctrl+Z – break current programm, continue fg (on forreground) or bg (in background)

Ctrl+D – logout, synonym exit

Ctrl+W – remove current word in the line

Ctrl+U – delete line

!! - repeat last command

exit – logout