≡ Menu

command line arguments

HowTo: Use Bash Parameter Substitution Like A Pro

The $ character is used for parameter expansion, and command substitution. You can use it for manipulating and/or expanding variables on demands without using external commands such as sed or awk.
[click to continue…]

Why many MCSEs won't learn Linux

Paul has responded to MCSE mike. Checkout my stand on Linux admin vs Microsoft Windows admin.

There are few basic principals under UNIX and Linux. Any MCSE must understand and follow them.

a) Everything is a file - Including your hardware.

b) All server / desktop configuration stored in text files - /etc, /usr/local/etc and ~/.dot-files. So learn to edit and search text files. Learn basis of grep, awk and sed along with vi. Same way all errors are logged in a text file located at /var/log/ directory

c) One small utility performs one single task at a time - Typical Linux box may have 2000-4000 command installed. Each command provides a single functionality.

d) Linux / UNIX is designed for simplicity - Add complexity only where you must.

e) Filters - Ability to chain programs together to perform complex tasks.

g) Interactive commands and dialog boxes are rare in UNIX / Linux - Learn to use commands, command line arguments and man pages.

Let the flame war begun ;)

Allow A Normal User To Run Commands As root Under Linux / UNIX Operating Systems

From my mail bag:

I would like to run few commands such as stop or start web server as a root user. How do I allow a normal user to run these commands as root?

[click to continue…]

Running Commands on a Remote Linux / UNIX Host

You would like to execute a command on a remote Linux/FreeBSD/Solaris/UNIX host and have the result displayed locally. Once result obtained it can be used by local script or program. A few examples:
=> File system and disk information

=> Get user information

=> Find out all running process

=> Find out if particular service is running or not etc

You can use rsh or ssh for this purpose. However, for security reason you should always use the ssh and NOT rsh. Please note that remote system must run the OpenSSH server.

Syntax for running command on a remote host:
ssh [USER-NAME]@[REMOTE-HOST] [command or script]


  • ssh: ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine.
  • USER-NAME: Remote host user name.
  • REMOTE-HOST: Remote host ip-address or host name, such as fbsd.cyberciti.biz.
  • command or script: Command or shell script is executed on the remote host instead of a login shell.


(A) Get disk information from a server called www1.cyberciti.biz:
$ ssh vivek@www1.cyberciti.biz df -h

(B) List what ports are open on remote host
$ ssh vivek@www1.cyberciti.biz netstat -vatn

(C) Reboot remote host:
$ ssh root@www1.cyberciti.biz reboot

(D) Restart mysql server (please note enclosed multiple command line arguments using a single or double quotes)
$ ssh root@www1.cyberciti.biz '/etc/init.d/mysql restart'

(E) Get memory information and store result/output to local file /tmp/memory.status:
$ ssh vivek@www1.cyberciti.biz 'free -m' > /tmp/memory.status

(G) You can also run multiple command or use the pipes, following command displays memory in format of "available memory = used + free memory" :
$ ssh vivek@debian.test.com free -m | grep "Mem:" | awk '{ print "Total memory (used+free): " $3 " + " $4 " = " $2 }'

See how to configure ssh for password less login using public key based authentication.

=> Related: shell script to get uptime, disk usage, cpu usage, RAM usage,system load,etc. from multiple Linux servers and output the information on a single server in a html format.