affiliate_link

Common SSH commands

I've compiled some of the common linux/unix shell commands. I believe this will be a great jumpstart for all *nix lovers like me.

Goodluck!


cd : change directory
ex. cd /root (brings you to the /root directory)
cd .. : moves you the upper directory
ex. if you're in /root
cd .. ( brings you to the cd / directory)

cd ~ : directs you to your home directory (/home)

cd - : brings you to the last directory you were in
cat : print file contents to the screen
syntax:
cat filename.txt - this prints the contents of the file filename.txt to your screen

ls : lists all the contents of a directory including all the files/directories in it.

ls -al : shows all files,directories,including hidden ones and the details/attributes for each file
ex.
[root@localhost var]# ls -al

total 220

drwxr-xr-x 27 root root 4096 Feb 5 20:25

drwxr-xr-x 23 root root 4096 Mar 22 23:11

chmod : changes the permissions of a particular file/directory.
Syntax:
From left to right:
USER - GROUP - EVERYONE

chmod filename

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


ex.
chmod 755 filename - gives read,write and execute permissions on the USER and read and execute permissions only to the Group and Everyone. This will look like:

drwxr-xr-x 3 root root 4096 Sep 5 2007 filename
chown : changes the file ownership
USER GROUP
drwxr-xr-x 3 root root 4096 Sep 5 2007 filename
Syntax:
chown owner.owner filename - this sets the owner of the user and group to "owner"
chown .owner filename - this sets the owner of the group to "owner"
Ex.
chown apache:apache filename
The output would be:
From
drwxr-xr-x 3 root root 4096 Sep 5 2007 filename
It will be
drwxr-xr-x 3 apache apache 4096 Sep 5 2007 filename

du - (disk usage) displays the file space allocated to each file and directory contained in the current directory

-a, display an entry for each file (and not directory) contained in the
current directory
-H, calculate disk usage for link references specified on the command line
-k, show sizes as multiples of 1024 bytes, not 512-byte
-L, calculate disk usage for link references anywhere
-s, report only the sum of the usage in the current directory, not for each
file
-x, only traverse files and directories on the device on which the pathname
argument is specified.
-h, show filesize in nice human readable format.

This prints the summary disk space usage of the current directory.

Ok so that's it for now. I will be updating this post from time to time so be sure to bookmark the link.


Cheers!

Recommended buys!

0 comments