basic linux commands
Linux

Linux commands for beginners part 2

0 1125

Linux commands for beginners part 2

Hi welcome to second part of  Linux commands for beginners .If you are feeling comfortable with Linux commands  you can surely easily understand the File Hierarchy System of Linux. Let’s start with  commands which are very useful for any linux Administrator.




We will start with very powerful command which is Pipe represented by sign (|). Basically it is used for redirect the output of one command into another command. Syntax command1 | command2.
See the practical example of pipe(|) in below screenshot.  First command is creating list of directory. Then output is piped  and its counting number of line of output which is 11.

In second command we are piping output of directory listing and displaying first 5 lines of listing.

[fahmed@faraz var]# ls -l | wc -l
24

[fahmed@faraz var]# ls -l | head -5
total 88
drwxr-xr-x. 2 root root 4096 Oct 30 2014 account
drwxr-xr-x. 15 root root 4096 Nov 5 2014 cache
drwxr-xr-x. 2 root root 4096 Oct 30 2014 crash
drwxr-xr-x. 2 root root 4096 Feb 2 2012 cvs

Now another kool command . I am going to change  lower case letters to upper case letters in file and vice versa.

Syntax tr ‘a-z’ ‘A-Z’ < file-name. See the below image;

trcmd

If you want to switch  user  then use su command

If you just type su and hit enter then it automatically switch to root.

If you have an ordinary user then type user-name.

Syntax su user-name.

sucmd





To view and change the host/machine name we can use command hostname.

Syntax hostname new-hostname. (Note: you must be on root privilege.)

hostcmd

free command is used to view the memory status.

Syntax free [option].
Useful options are free –l (show the memory with detail),
free –m (show the memory with Mbs),
free –g (show the memory with Gbs).

[fahmed@faraz var]# free
             total       used       free     shared    buffers     cached
Mem:      22540264    2007488   20532776          0     234092     573932
-/+ buffers/cache:    1199464   21340800
Swap:     11530232          0   11530232
[fahmed@faraz var]# free -l
             total       used       free     shared    buffers     cached
Mem:      22540264    2007620   20532644          0     234096     573928
Low:      22540264    2007620   20532644
High:            0          0          0
-/+ buffers/cache:    1199596   21340668
Swap:     11530232          0   11530232
[fahmed@faraz var]# free -m
             total       used       free     shared    buffers     cached
Mem:         22011       1960      20051          0        228        560
-/+ buffers/cache:       1171      20840
Swap:        11259          0      11259
[fahmed@faraz var]# free -g
             total       used       free     shared    buffers     cached
Mem:            21          1         19          0          0          0
-/+ buffers/cache:          1         20
Swap:           10          0         10

du command is used to view the used disk space by any directory.

Syntax du dir-name.
Useful options are du –c (show the grand total),
du –h (human readable form),
du –s (show only a total size).

ducmd

df is used to view the free disk space.

Syntax df dir-name.

Useful option is df –h (human readable form).

df

which command is used to show the full path of commands.

Syntax which command-name.

whichcmd

Whatis command is used to show the short description about command.

Syntax whatis command-name.

whtiscmd

whereis command is used  to locate the binary, source and manual pages.

Syntax whereis command-name.

whriscmd

I hope you have enjoyed tutorial. See you in next tutorial

Thanks

SUBSCRIBE OUR NEWSLETTER
Join us by subscribing to our newsletter and learn IT subjects for free
We hate spam. Your email address will not be sold or shared with anyone else.

Leave a reply

You must be logged in to post a comment.