This site is currently
Under Construction
...soon to be...

Commandline Tools (Linux/Unix)

Last updated: 2009-06-31

===

Manual Info:
# man <command_name>

OS Version:
# uname -a

OS Version and CPU:
# uname -ap

Process Statistics - Sorted by CPU utilization
# top
# ps -aux
# systat

System Statistics - Sorted by CPU utilization
# top

Adding a user:
# adduser

Remove a user:
# rmuser <username>

Checking disk usage:
# df -ht ffs

Restart OpenSSH without rebooting:
# kill -HUP `cat /var/run/sshd.pid`

Using netstat:
# netstat -a -f inet

Checking network usage statistics:
# netstat -s

Check disk usage of the home directories:
# du -sh /home/*

Finding a file, searching the entire directory structure:
# find / -name bsd

Adding a user to a group:
# usermod -G <group> <username>

List Open Files:
# fstat

Partition/Disk Info of Mounted Partitions:
# df -h
# disklabel wd0 (disklabel <drive>)

Locate File Anywhere:
find / -name <filename>

Update Locate Database:
updatedb
or
/usr/libexec/locate.updatedb

Locate file in cached database:
locate <filename>

Copying a File:
# cp origfile newfile

Renaming a File:
# mv oldfilename newfilename

Removing a File:
# rm filename

Creating a Directory:
# mkdir dir_name

Moving or Copying Files Into a Directory:
# mv filename dir_name
# cp filename dir_name

Renaming a Directory:
# mv orig_dir_name new_dir_name

Copying a Directory:
# cp -r orig_dir_name new_dir_name

Removing a Directory(s) if empty:
# rmdir dir1 dir2
(Note: rmdir will not remove a directory if it is not empty in UNIX.)

Remove Directory plus All Files and Tree of Directories below:
# rm -r dir

Creates a Symbolic (Soft) Link to a file:
# ln -s <real_path_filename> <linkname>

Creates a Hard Link to a file:
# ln <real_path_filename> <linkname>

List Symbolic Links Only:
# find <path> -type l

Export:
# export <variable_name>=<value>

Unset:
# unset <variable_name>

Shutdown and Reboot:
# shutdown -r now

Shutdown and Halt:
# shutdown -h now

Reboot:
# reboot

===

Return Command Result to Variable:

# <variable>=$(<command_string>)

Examples:

# INT1=$(ls)
# echo $INT1

# INT1=$(ip route show | grep 192.168.1.0 | cut -d ' ' -f 3)
# echo $INT1
ppp0

===

Echo Variable to a File:

If you need to echo a variable to a file, you can either send the variable value to the file or the variable name, depending on your needs. Simply preceed the "$" with the backslash "\" to escape the $ creating the variable value in your file.

Examples:

# INT1=test
# echo "$INT1"
test

# INT1=test
# echo "\$INT1"
$INT1

===

Reference Links:

http://www.pixelbeat.org/cmdline.html

===