Enable Dark Mode!
basic-ssh-commands-in-linux.jpg
By: Gion Dany

Basic SSH Commands in Linux

Technical

SSH (Secure Shell or Secure Socket Shell) is a network communication protocol that allows communication between two systems. It connects securely to a remote server. Also, it supports SCP(Secure Copy Protocol) and SFTP(SSH File Transfer Protocol) for data transfer.

To connect to your server (system) and transfer data to your system using a graphical user interface or command line.

Methods for establishing an SSH connection:

Putty

Launch the PuTTY SSH client, then enter your server’s SSH Host Name (or IP address) and Port. Click the open button to continue.

basic-ssh-commands-in-linux-cybrosys

Command prompt

Specify the username and the host in the following format

ssh user_name@host(IP/Domain_name)

user_name: represents the account that accesses the host.

host: refers to the accessing machine, which can be a computer or a router. This can be an IP address (e.g., 20.40.202.16) or domain name (e.g.www.cybrosys.com).

List of Basic SSH Commands

SSH CommandExplanation
lsShow directory Contents(list the name of files)
cdChange directory
mkdirCreate a new Folder
rmRemove a File
pwdShow current directory(full path to where you are right now)
cpCopy file/folder
mvMove file/folder
catShow contents of a file
grepSearch for a specific phrase in file/lines
findSearch files and directories
vi/nanoText editors
historyShow the last 50 used commands
clearClear the terminal screen
tarCreate & Unpack compressed archives
wgetFile downloading from the internet
duGet file size

ls command

ls command is used to list all files and directories.

Syntax: ls [options] [paths]

cybrosys@cybrosys:~/cybrosys$ ls
odoo14    odoo15    odoo16

ls -l: Display the important information about the file.

cybrosys@cybrosys:~/cybrosys$ ls -l
total 12
drwxrwxr-x 2 cybrosys cybrosys 4096 Aug  7 14:16 odoo14
drwxrwxr-x 2 cybrosys cybrosys 4096 Aug  7 14:16 odoo15
drwxrwxr-x 2 cybrosys cybrosys 4096 Aug  7 14:16 odoo16

ls -a: List all files and hidden files in the directory.

cybrosys@cybrosys:~/cybrosys$ ls -a
.  ..  odoo14  odoo15  odoo16

cd command

cd (change directory) is used to jump into the directory.

Syntax: cd [directory]

cybrosys@cybrosys:~/cybrosys$ cd odoo15
cybrosys@cybrosys:~/cybrosys/odoo15$

cd .. - Takes you to the previous directory.

cybrosys@cybrosys:~/cybrosys/odoo15$ cd ..
cybrosys@cybrosys:~/cybrosys$ cd
cd / - Takes you to the root directory.
cybrosys@cybrosys:~$ cd cybrosys/odoo15
cybrosys@cybrosys:~/cybrosys/odoo15$ cd /

mkdir command

mkdir (make directory) command is used to create a new directory.

Syntax: mkdir [directory_name]

cybrosys@cybrosys:~/cybrosys$ mkdir odoo13
cybrosys@cybrosys:~/cybrosys$ ls
odoo13    odoo14    odoo15    odoo16

touch command

the touch command is used to create a file.

Syntax: touch [file_name]

cybrosys@cybrosys:~/cybrosys/odoo15$ touch cybro_odoo
cybrosys@cybrosys:~/cybrosys/odoo15$ ls
cybro_odoo

rm command

the rm command is used to remove a file.

Syntax: rm [file_name]

cybrosys@cybrosys:~/cybrosys/odoo15$ rm cybro_odoo
cybrosys@cybrosys:~/cybrosys/odoo15$ ls
cybrosys@cybrosys:~/cybrosys/odoo15$

rm -r: Delete a folder, it removes all files and subfolders in it.

rm -i: Ask for confirmation, before removing the file.

pwd command

Gets the full path of your working directory

Syntax: pwd 

cybrosys@cybrosys:~/cybrosys/odoo15$ pwd
/home/cybrosys/cybrosys/odoo15

cp command

cp is used to copy files or directory

Syntax: cp [option] [source] [destination]

cp -R source_directory destination_directory: recursive copying of directories. ( If the destination_directory doesn’t exist, cp creates it and copies the content of source_directory recursively as it is. But if destination_directory exists, then a copy of source_directory becomes a sub-directory under destination_directory)

cybrosys@cybrosys:~/odoo15$ cp cybro_odoo /home/cybrosys/odoo14
cybrosys@cybrosys:~/odoo14$ ls
cybro_odoo

mv command

mv is used to move files or folders.

Syntax: mv [option] [source] [destination]

cybrosys@cybrosys:~/odoo13$ ls
cybro
cybrosys@cybrosys:~/odoo13$ mv cybro/ /home/cybrosys/odoo15
cybrosys@cybrosys:~/odoo13$ cd /home/cybrosys/odoo15
cybrosys@cybrosys:~/odoo15$ ls
cybro  cybro_odoo
cybrosys@cybrosys:~/odoo15$

grep command

This command is used to search for the specified text in a file.

Syntax: grep [search_word] [file_name]

cybrosys@cybrosys:~/cybrosys/odoo15$ cat cybro_locations
Calicut
Kochi
Banglore
UK
cybrosys@cybrosys:~/cybrosys/odoo15$ grep Kochi cybro_locations
Kochi
cybrosys@cybrosys:~/cybrosys/odoo15$

cat command

It is used to display the content of a file.

Syntax: cat [file_name]

cybrosys@cybrosys:~/cybrosys/odoo15$ cat cybro_odoo
Cybrosys Technologies is a private limited company that engrosses with technology and software business to deliver quality software products worldwide.
Cybrosys, with infrastructure facilitating sophisticated and adequate lab facilities for research and development, has more than 100 innovative and highly dedicated members. Our strategic software partnership with ODOO, MICROSOFT, IBM, Intel, HP, NASSCOM etc. and other technology giants has supported our process in making our presence worldwide within a short span of time. Our product and services are used with clients across India, USA, UK, Middle East & Europe.
cybrosys@cybrosys:~/cybrosys/odoo15$

vi/nano command

vi and nano are the text editors. To create or open a file using Vi or Nano.

Syntax: nano [file_name] / vi [file_name]

cybrosys@cybrosys:~/cybrosys/odoo15$ nano cybro_locations
cybrosys@cybrosys:~/cybrosys/odoo15$

Or

cybrosys@cybrosys:~/cybrosys/odoo15$ vi cybro_locations

history command

history is used to display the last used commands

Syntax: history

cybrosys@cybrosys:~/cybrosys/odoo15$ history 2
  1  nano cybro_locations
  2  history 2
cybrosys@cybrosys:~/cybrosys/odoo15$

clear command

clear is used to clear all text from the terminal screen.

Syntax: clear

cybrosys@cybrosys:~/cybrosys/odoo15$ clear
cybrosys@cybrosys:~/cybrosys/odoo15$

du command

du (Disk Usage) command shows disk block numbers

Syntax: du [options][file_name]

cybrosys@cybrosys:~/cybrosys/odoo15$ du cybro_odoo
4    cybro_odoo

du -h: Shows the disk block numbers instead of bytes

cybrosys@cybrosys:~/cybrosys/odoo15$ du -h cybro_odoo
4.0K    cybro_odoo

du -a: Shows the space usage of each file in the directory.

wget command

This command is used to download files from the Internet. It supports downloading multiple files.

Syntax: wget [option][url]

cybrosys@cybrosys:~/cybrosys/odoo15$ wget https://www.cybrosys.com/
--2022-08-07 18:55:21--  https://www.cybrosys.com/
Resolving www.cybrosys.com (www.cybrosys.com)... 20.40.202.16
Connecting to www.cybrosys.com (www.cybrosys.com)|20.40.202.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71607 (70K) [text/html]
Saving to: 'index.html.1'
index.html.1                          100%[=====================================================================================>]  69.93K  67.2KB/s in 1.0s    
2022-08-07 18:55:24 (67.2 KB/s) - 'index.html.1' saved [71607/71607]
cybrosys@cybrosys:~/cybrosys/odoo15$ ls
 cybro     cybro_locations   cybro_odoo  'Cybrosys Techno Solutions Pvt.Ltd?unique=5f325aa'   index.html     index.html.1
cybrosys@cybrosys:~/cybrosys/odoo15$

Other SSH Commands

ssh-keygen: Generating new authentication key pairs for SSH

ssh-copy-id: Copying SSH keys to servers

ssh-agent: Hold private key used for public key authentication

ssh-add: Adding private keys to the SSH authentication agent to implement single sign-on using SSH

scp: Securely copy files and directories between two locations.

sftp: Transfer files directly between two servers.

sshd: OpenSSH server process

SSH commands are essential for managing Linux servers. This is the most efficient way to navigate your system and modify files and folders.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message