Convert Microsoft to LINUX: Intro to Linux Commands

There are hundreds of Linux commmand line commands out there. Here I will attempt to give you the most important basic ones. These commands can be typed at any terminal prompt . Note, many of them require you first be logged in as root (su) before you can issue them. I have placed them in alphabetical order using a MySql database. Please let me know, if you feel I have left out your favorite most used command, by clicking here.

Note, if you are familiar already with Linux or UNIX commands and want a good source for comparing the same command on various platforms (Linux, Solaris, HP-UX, MAC OSX, etc.), please go to the rosetta stone.

Abbreviated List of Linux Commands

bzip2 -d filename.tar.bz2  

Use this to unzip a bz2 file. For example type:
bzip2 -d ../firefox-3.5.5.tar.bz2
to unzip the latest version of firefox which lives in a directory right above this one. Note, it will create a file with just the .tar extension overwriting itself. You can then use the standard tar command , i.e.:
tar -xvf ../firefox-3.5.5.tar


/etc/apache2/httpd.conf  

This is where the Apache 2 Webserver config file lives in Ubuntu. To install type:
apt-get install apache2
This will work in all flavors of Ubuntu or Debian systems.


/etc/crontab  

This is where the crontab file lives used to execute system jobs regularly throughout the day.


/etc/exports  

This is the file which determines which directories are exported for NFS (Network File Systems). Here is a sample:
/home/user1 192.168.0.0/255.255.255.0(rw)
/home/victor 192.168.0.0/255.255.255.0(rw)


/etc/fstab  

This automatically generated when installing. You may have to tweak it some times to make sure all the file systems you want are mounted. Here is my Ubuntu MAC fstab :
# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
/dev/hda5 / ext3 defaults,errors=remount-ro 0 1
/dev/hda2 none swap sw 0 0
/dev/hdb /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/sdb /media/floppy0 auto rw,user,noauto 0 0
/dev/hda3 /media/MAC hfsplus defaults 0 2

Here is my Kubuntu /etc/fstab:
# /etc/fstab: static file system information.
# This is for Kubuntu with a Fat32 Windows XP (vfat) automounted on partition 12
#
proc /proc proc defaults 0 0
/dev/hda6 / ext3 defaults,errors=remount-ro 0 1
/dev/hda5 none swap sw 0 0
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/hda12 /mnt/data vfat defaults 0 2

Note, a value of 0 for the last column disables automatic file system checking at boot.


/etc/samba/smb.conf  

This is where the Samba Server config file normally lives. It is used for creating a Primary Domain Controller for Microsoft Windows, printing and file sharing on the UNIX/Linux/MS Windows network. It is done using the netbios tcpip protocol on port 139.
click here to see my web page section on this.


/etc/X11/xorg.conf  

This is a very important file for getting your graphical GUI X Windows interface working. Usually the only thing that is a problem is the display or resolution. I have included two samples here. Please back up your file, before using these. i.e.
cp xorg.conf xorg_orig.conf
For Ubuntu Feisty to fix bug on laptops such as Evo N1000C
click here
For Mandriva to fix similar bug on laptop
click here
Please also see this link for an explanation: click here


/var/www/myapp  

Default Directory for Ruby on Rails.


1080  

TCP Port for Socks Proxy Sever. This is used for example to force all internet traffic through one server. This server can cache the web pages and if there is any trouble it can be shut down to protect the network.


110  

TCP Port POP3 (Post Office Protocol 3) for checking incoming email.


1352  

TCP Port for IBM Lotus notes. Lotus notes was a popular software with MS Office type functionality in the 1980's.


139  

TCP Port NetBIOS. Used by Microsoft , Samba and the original DOS TCPIP stack.


143  

TCP Port IMAP4 (Intenet Message Access Protocol 4) used for retreiving emails. This has more advanced features such as calendar support and ability to save attachments/messages on the server.


1494  

TCP Port for Citrix Metafame ICA client. This is used with terminal servers running Citrix Software.


161  

UDP Port for Simple Network Management Protocol (SNMP).


20  

TCP Port for FTP Data


21  

TCP Port for FTP Command control


22  

TCP Port for Secure Shell. This is encrypted.


23  

TCP Port for Telnet. This is not encrypted.


25  

TCP Port for Simple Mail Transfer Protocol (SMTP). This is commonly used for outgoing mail.


389  

TCP Port for LDAP (Lightweight Directory Access Protocol)


443  

TCP Port for HTTP over SSL(Secure Socket Layer). This is also known as HTTPS, secure HTTP. It uses encrypted transmission.


445  

UDP Port for Samba File sharing also used by Microsoft.
Microsoft also uses this as a TCP Port for Active Directory and Windows Shares.


465  

TCP Port for SMTP over SSL. Note this gives encrypted outgoing mail but conflicts with a registered CISCO protocol.


53  

UDP Port for Domain Name Services. (DNS)


6000  

TCP Port for X11 Linux/UNIX X Windows protocol.


636  

TCP Port. LDAP over SSL. Secure transmission.


67  

UDP Port for Boot P protocol for remote boot. Also used for Dynamic Host Configuration Protocol. (DHCP)


68  

UDP Port for DHCP.


69  

TCP Port Trivial File Transfer Protocol (TFTP)


80  

TCP Port Hyper Text Transfer Protocol. Used for web pages. This is not secure.


873  

TCP Port for rsync file synchronization command. See explanation of rsync in this command list.


901  

TCP Port for Samba Web Administration Tool (SWAT).


993  

TCP Port for IMAP4 over SSL. This is encrypted.


995  

TCP Port for POP3 over SSL. This is encrypted.


admintool  

Administration Tool for Solaris


alsa force-reload  

This is for the sound in Linux. Use this command to force the alsa pulseaudio modules to reload. You need to run it as the root user. Also make sure under Pulse Audio Volume Control, under the Sound and Video Settings, you have the output devices set to Port | Speakers.


alsactl init  

Assuming you are root, type this at the terminal prompt. This will turn your sound card on. Sometime on an install Linux forgets to do this.


apt autoremove  

This is a command you do as root at the terminal prompt. You can not do it too much. It is especially good when new init.img images for booting the system are added. Doing this will remove all the old boot images safely that are no longer used. Do not do it yourself by using the rm command. Also, if you have several versions of Linux on the same machine, log into the system that has the grub image for booting up and type:
grub-install /dev/sda
update-grub


apt-get install package  

Used for Debian based distributions. i.e.: apt-get install firefox
To install the gcc compiler in Ubuntu:
apt-get install gcc
If that does not completely succeed, additonally type:
apt-get install build-essential
To install Samba in Ubuntu type:
apt-get install samba
You will probably want additionally the web configuration tool swat
apt-get install swat
Note, make sure you have a local webserver up so you can use swat by typing:
http://localhost:901


arp -a  

Display the arp entry table. The above gives on my home system:
dslmodem.domain.actdsltmp (192.168.0.1) at 0:20:e0:55:d0:8b
arp stands for Address Resolution Protocol . It connectes the IP Address to the Hardware Address of the physical device. Here it is the NIC card in the DSL router.


awk  

This is a very powerful command for editing files and processing list type output. It is particularly useful if you want to create a google group . This is a very awkward process, so therefore use awk. If you have awk at linux, unix,bsd or some similar operating system type:
awk 'NR%10==1{x="F"++i;}{print > x}' testme.txt
This assumes your list of emails (testme.txt) which has just the email followed by a comma, that is you do not see the real name of the person. The file name is kind of dumb here, so the first file will be F1, the second F2 and they will each have 10 lines in them. The real bear is going through all the nonsense to verify that you are a human and not a troll on the web. You would think just a simple addition or question like who is president would be enough. Google does not make it easy, but at least the person you invite has full control whether or not to join the group and can leave/unsubscribe at any time.


cat filename | more  

Display a text file on the screen. i.e. : "cat menu.lst | more " . Note the " | more " is not necessary if it is a small file. You can hit the space bar to page through the file.


cd  

Change to a given diretory. i.e. "cd /home/user1"


CD/DVD Creator  

Use this on a Gnome desktop such as Ubuntu to burn CD/DVD's. You will find it as a drop down menu item under "Places" on the top horizontal toolbar.


chmod parameter dir/filename  

This is used for changing the permission on a file or directory. i.e.
chmod 777 /home/desktop/victor
will enable the owner, group and world to read, write and execute all files in the directory. Note that the 7 is an octal value represented as three bits 111 giving a total of 7. The first bit is the read bit, the second bit is the write bit and the third bit is the executable bit.
chmod +t /home/desktop/victor
or
chmod 1755 /home/desktop/victor
This enables the sticky bit. Only the owner of that directory or the owner of a file can delete or rename a file within that directory. This is a very good protective device, especially on web pages. In the old days this kept a file in executeable memory. It is not used for that purpose anymore.
You can also use chmod to set the System User ID bit. Use the number 4 before your normal file permissions for this file. This is done for example with the binary executeable to change a password.
chmod 4555 /usr/bin/passwd
If you list the file you will see:
ls -al /usr/bin/passwd -r-sr-xr-x 1 root wheel 30492 Nov 26 2006 /usr/bin/passwd
The s denotes that the System User ID bit is set so a normal user can run this to change their password.
Similarly you can set the System Group ID bit on with the prefix 2 for the file permissions. This will enable those who are not a member of that group to execute the file, based on the privileges of the group that file belongs too. . i.e.:
chmod 2750 /home/finance/dailystats
Therefore somebody who is not a member of the finance group can execute the dailystats program. Note, whenever you use any of the SGID or SUID bits there is a security risk.


chown www-data:web *  

This is the change owner command. This is used to restrict permissions on a file or directory. Only the person "www-data" in the group "web" can edit the files/directories.


Control Key Sequence  

These keys are very useful at the command line or in editors. You create them by holding down the control key and a letter of the alphabet at the same time. i.e.
ctrl - c , will cancel a command.


cp filename1 filename2  

Copy a file, i.e. cp menu.lst menu_save.lst
Note, this can also be used to copy directories recursively with:
cp -r /var/www/sites_us /backup/www/sites_us


crontab  

Use this command to view the jobs that are regularly run at the system level.
crontab -l
will list the jobs to be run. To edit the file type:
crontab -e
To create a crontab, you use the crontab command with the -e (for "edit") option.
If you get a number when you do crontab -e
You need to set the VI editor properly with:
export EDITOR=vi

Each crontab entry contains six fields:
1. Minute
2. Hour
3. Day of the month
4. Month of the year
5. Day of the week
6. String to be executed by sh
Minutes and hours range from 0-59 and 0-23, respectively, while day of month and month of year range from 1-31 and 1-12, respectively. Day of week ranges from 0-6, with 0 being Sunday. Day of week may also be specified as sun, mon, tue, and so on. The sixth field is everything after the fifth field, and is interpreted as a string command to pass to the shell interpreter. Note, an * in a field denotes all permissible values. i.e.
15 0 * * * /home/prod/dailybkup
would cause the daily backup program to run every day at 12:15 AM of the year. The fields are separated by spaces or tabs. A comma can be used when denoting multiple values for a field. This would run the same daily backup program twice a day:
15 2,20 * * * /home/prod/dailybkup
at 2:15 AM and 8:15 PM.
Here is another daily backup using tar and gzipping it:
30 0 * * * tar -czf backup.tar.gz /home/victor/
Note, I used the home directory ~ here.
Enjoy!


ctrl - c  

Cancel a command


ctrl - d  

Used for exit, logout or to signal the end of a text file. i.e.:
cat > testfile.txt
once upon a time
ctrl -d
This will create the file testfile.txt.


ctrl - g  

This is the Bell.


ctrl - i  

Tab key (horizontal) in the forward direction.


ctrl - j  

This is the linefeed character. It is like rotating the old typewriter by one line.


ctrl - m  

This is the carriage return. This is like pushing an old typewriter back to the beginning (left margin). This key is very useful if you hit the enter key and you are not getting to the next line. Note, DOS files have a linefeed and a carriage return at the end of each line. UNIX/Linux text files only have linefeeds.


ctrl - n  

This is a vertical tab. It is also often used to denote "the next thing", in many applications. i.e.
If you read in more than one file in vi , the Visual Editor in UNIX/Linux, this will jump you to the next file to edit.


ctrl - o  

This is the formfeed character. It is useful in printing for advancing the page.


ctrl - [  

Holding down the control key and the left square bracket, it the equivalent of hitting the escape key. Note, that is a bracket not a squigley.


curl url  

This will give you in text mode at the commandline what a web page sends. i.e.
curl converttolinux.com

You can find out more information if the host will provide it such as the operating system you are running on with the -I parameter as in:
curl -I www.scn.org | grep Server
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed 0 13222 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
Server: Apache/1.3.20 (Unix) mod_ssl/2.8.4 OpenSSL/0.9.6b PHP/3.0.18


Note you can subsitute --head instead of -I which will also return the HTTP Header Information


date  

List the date and time of the server. Below is an example of the output.
Thu Feb 8 16:47:32 MST 2001

To set the date of your server to the date and time shown:
date -s "11/20/2003 12:48:00" .
date '+DATE: %m/%d/%y%nTIME:%H:%M:%S'
Would list the time and date in the below format.

DATE: 02/08/01
TIME:16:44:55
do man date for more details, also see on this web page under touch


dd  

Perform an image level backup. i.e.:
dd if=/dev/c0d0s0 of=/dev/rmt/1
Here "if" is the input file device and "of" is the output file device, which is a tape drive here.
If you want to copy a DVD or CD .iso image file to your desktop here is how:
dd if=/dev/dvd of=./Mandriva2006.iso
Note, this was necessary for burning the image using the k3b burner. Otherwise a file needs to be created in /tmp for copying a DVD which can get very big. Note, I assumed you were in a directory of /home/user1/Desktop when you issued the previous dd command.
Lastly you can use dd to securely delete all the data on a hard drive with:
dd if=/dev/zero of=/dev/hda
This will write zeroes to the entire first hard drive device.
To blank a CD in Ubuntu type:
sudo dd if=/dev/zero of=/dev/sr0
Note, sr0 is the CD device.

To create a USB Stick from a CD or DVD ISO image use:
dd if=/home/victor/downloads/suse-live-12.1-iso of=/dev/sdb bs=4M
Note, that is sdb not sdb1. Once you use sdb1 you are putting it on a partition of the USB and that confuses the heck out of the bootloaders out there. You will get errors like:
"isolinux.bin install missing or corrupt"
"There is no CD in drive 1"


df  

Display Free Space on File System. Use:
df -h
on Solaris to display data in human readable form (like Linux).


dhclient  

Launch dhcp client to assign an IP address to a network device.


dhcpmgr  

Solaris GUI tool for managing DHCP Server.


diff  

Compare two files showing differences. i.e.:
diff file_a file_b
Consult man pages for more info. There are many switches here you can use.


dig Servername  

Get Domain Name Service and Bind info about a server. i.e.
"dig www.msn.com"


dpkg (Debian Package Manager)  

This is what actually does the work on a Debian system such as Ubuntu when you run apt-get install progname
apt-get is the high level interface. Here are some of the lower level commands. Note, they are case sensitive:
dpkg -i firefox.deb
Install firefox from a Debian package.
dpkg -R /usr/local/src
Install all packages recursively from this directory. Very powerful!
dpkg -r firefox.deb
Remove package firefox except configuration files.
dpkg -P firefox.deb
Remove, that is purge, package firefox.deb including configuration files.
dpkg -c firefox.deb
Display Contents of package.
dpkg -I firefox.deb
Show info about this package.
dpkg -l
List all packages installed with a short description.
dpkg --version
Get version of package manager.
dpkg -L apache2
List directories where files are installed for apache2.
dpkg -S apache2
Search for all files installed for apache2.This will be real big.
dpkg -s apache2
Get status of apache2 on this system to find out if it is installed. This includes dependencies.
dpkg --help
This along with the man pages will give you more info.

dpkg --get-selections | grep php
This will show you all your installed php packages.
Enjoy!


dpkg-reconfigure xserver-xorg  

This program is very useful for configuring your xorg.conf file. It will in text mode step you through all the entries including keyboard, video, monitor, mouse etc. It is used with display problems. See this.


du  

Display disk usage statistics.


dump  

Tool for performing full and incremental backups of File Systems in Linux and HP-UX.i.e:
dump 0f /dev/st0 /
This will backup all files from the ROOT directory to the tape device "/dev/st0"


echo $PATH  

Display the built in paths you have access to. If you do not see the path you will have to expicitly type the full directory name or add it to your environment variable if you have privileges to do this. i.e.:
shanti> echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin


emerge package  

This is the Gentoo Linux way of installing a software package. i.e.
emerge openoffice
(This will take a while.)


export PATH=  

Use this to reset your path if you mess it up or add to the current one.
export PATH=/home/victor:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin:/bin:/usr/games
or to add to a current directory:
export PATH=/home/victor/desktop:$PATH
This will add /home/victor/desktop to your current path at the front. You can type:
echo $PATH
to see how your path is currently set.


exportfs  

Used with NFS (Network File System) to show all available file systems over the network.


fdformat -U floppy  

Format a floppy disk on Solaris.


fdisk -l  

Display partition table for hard drive.
i.e., fdisk -l for the ROOT user gives:
Disk /dev/hda: 60.0 GB, 60011642880 bytes 255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 214 1718923+ b W95 FAT32
/dev/hda2 215 1020 6474195 83 Linux
/dev/hda3 1021 7296 50411970 5 Extended
/dev/hda5 1021 1151 1052226 82 Linux swap / Solaris
/dev/hda6 1152 2171 8193118+ 83 Linux
/dev/hda7 2172 3191 8193118+ 83 Linux
/dev/hda8 3192 4211 8193118+ 83 Linux
/dev/hda9 4212 5231 8193118+ 83 Linux
/dev/hda10 5232 6251 8193118+ 83 Linux
/dev/hda11 6252 6761 4096543+ 83 Linux
/dev/hda12 6762 7296 4297356 b W95 FAT32


fgrep pattern filenames  

This is like grep put can search all the files requested. i.e.:
fgrep 'SSL/TLS' *
This will search all the files in the current directory and tell you which ones contain the string 'SSL/TLS'. Note, the line number is also given for the particular file.


find -type d -exec chmod 777 -R {} \;  

The above command will change directories for all directories recursively including the current directory
Sometimes you may need to do this, but it is generally not a good idea.


find -inum  

Use this in combination with the xargs argument to delete a file that may have lots of special characters in it. i.e.:

find -inum 2093069 | xargs rm
See the stat command to see how we got the inode number.


find ./ -name filename  

This will find a file beginning the search at the directory stated. Here ./ represents the current directory. i.e.:
find ./ -name index.shtml
Note, you probably want to be in the root directory when beginning your search. i.e. type first:
cd /
find ./ -mtime -1 -type f
This will find all the files that were changed in the last day starting from the current directory.


format  

Disk partition tool on Solaris, similar to fdisk on Linux.This is very powerful, use carefully! Type it all by itself then select the number for the disk you want to look at. i.e. "0" will be for the first hard disk. You can then type:
partition
to see a partition menu. You can then select
print
to print out a partition map. See man pages for more info.


fsck devicename  

File System check. Happens automatically at boot for each partition. You can check them individually with:
fsck /dev/hda2
Note, on my system the second partition was a Solaris drive which Ubuntu was failing when it checked. I turned off fsck for this drive by editing /etc/fstab
The last column also known as the pass column has to be set to 0 to turn off automatic file system checking. The default is 2 which forces a check.


ftp  

File Transfer Protocol for moving files between clients and Servers. For security sftp (secure ftp) is preferred. This encrypts your data. ftp has no encryption.


gcc  

This is the GNU compiler. It includes many languages among them C, C++ and FORTRAN. Here is an example:
gcc hello.c
This compiles a C program called hello.c giving a hello.o object and an a.out executeable file. Here is the text of hello.c:
main()
{
printf("Hello Gnome Programmers \n");
}


gdm  

Launch the GNOME graphical display manager interface.


get filename  

Used to retrieve files from a website or FTP Server. i.e. get install.txt Note you can also use wildcards here. i.e. : "get *.txt" to retrieve all text files.


git show  

This shows everything in git log, plus info about all the objects created.


git add  

You have just modified a file, so now you need to add it and then later commit it.

git add intro.txt


git blame filename  

Here is an example:
git blame ./lib/intro.txt
3d912549 (victor 2012-04-30 16:45:07 -0700 1) This is the lib directory for putting in library entries.


git branch  

Show what branch you are on. The default is master.


git checkout -b branchname  

This will create a new branch and switch to it. i.e.

git checkout -b development

git checkout production

This will change you to the production branch.


git cherry-pick [commit-address]  

Often in the real world a developer may be pressed to quickly fix a bug and not do the normal protocol of first fixing in on the development branch, testing it, merging it. That is committing it and then pushing it up to production. Here is how to make things be synchronized.

Go to the production branch:
git checkout production
$ git log -1 commit e458a9b309acb5d937b360aa3140631dc7af0b1e Author: M Butcher <...@aleph-null.tv> Date: Fri Dec 4 17:30:19 2009 -0600 Bug fixes for :contains() pseudo-class. Strip backslashes from processed content, strip quotes from :contains() contents. That's the commit record you need , so copy the first few characters of the commit address:
Now use the cherry-pick on that module.

git checkout development
git cherry-pick e458
Do a
git status
and you should see everything is committed now. Also do
git log
to verify all is ok. You should see the developer's comments there now.


git clone [url]  

git clone http://github.com/schacon/simplegit.git

The above will grab some code off a website and clone it to the current directory. A directory will be created underneath the current one here of simplegit You may have to first install git with:
sudo apt-get install git


git commit -m "file comit message" [-a]  

This will commit all the actions since the last commit. No worries, you can always undo it later. When you check the status you may see that you are now ahead of your origin/master
This simply means you would have to push these changes up to where you originally cloned from, if you wanted everything to be in sync. Don't do this until you have done all your local testing first.

If you do not use the -m the editor will be brought up. If you use the -a option all the files which have been changed will automatically have the git add
done on them. Use this option carefully as you may be committing more than you want to.


git diff  

See what has changed since the last commit.

git diff origin master
This will show the difference between the origin where you cloned from and the current branch which is in this case master.


git init  

This will use git to initialize the current directory as a respository. A .git directory will be created. If you just cloned a directory from the web, this will automatically be done.


git log  

This will show you all the commits and actions that you have done, including the comments you have entered when committing files.


git pull  

this is a combination of
git fetch
and
git merge

You may have to resolve conflicts if there are merge errors.Being more explicit, it would probably be
git fetch origin
git merge development
Assuming you are on the development branch.


git push [ --dry-run ]  

push committed files up to remote branch. You can use the --dry-run parameter to see which files would be pushed up before doing the real thing. Without the dry run being more explicit it would be:
git push production
This is assuming that your fetch from an origin branch, test on a development branch which you merge with and finally push all the committed files up to your production branch.


git reflog  

This will give you your reference log for every time you do some kind of major reset. This is your safety net if you mess up. Here is an annotated examle:

git reflog
ca82a6d HEAD@{0}: HEAD^: updating HEAD
3d91254 HEAD@{1}: commit: Committing my first file.
ca82a6d HEAD@{2}: clone: from http://github.com/schacon/simplegit.git

I had done a few
git reset --hard HEAD^
which resulted in my looseing a file I had created called intro.txt in the lib directory. Here you see it is gone:

Now it will be returned:
victor@victor-900HA:/tmp/simplegit$ find ./ -name intro.txt
victor@victor-900HA:/tmp/simplegit
$ git reset --hard HEAD@{1}
HEAD is now at 3d91254 Committing my first file.
victor@victor-900HA:/tmp/simplegit$ find ./ -name intro.txt
./lib/intro.txt


git remote -v  

Show what your remote branch status is. Here is an example:

origin http://github.com/schacon/simplegit.git (fetch)
origin http://github.com/schacon/simplegit.git (push)

This shows where a fetch would come from and where a push would go.


git reset --hard start-tag  

Resest everything to the tag value start-tag that you made when you started your work today.

git reset --hard HEAD
This will set you back to the last commit.

git reset --hard HEAD^

This sets you back to the next to the last commit.Be careful here.


git rm filename  

This is a better way to do it then straight rm because you can get everything back with git reset


git status  

This will tell you what branch you are on. By default the master branch is created. It will let you know if you have made changes and need to commit them. This is analagous to committing an entry in a database. If you do not commit you can lose your changes. Here is a sample:

git status
# On branch master
nothing to commit (working directory clean)


git tag -a tagname [commit address]  

This is a convenient way to mark where you currently are. You can do this at the start of a day or week when you work.
git tag -a vers-1.0 13c10

Always use the -a which forces annotation and produces a nice log record for the tag.If you leave off the address it will default to HEAD that is everything done up until the last commit.


grep -i "pattern" -r [files or directory]  

Search for a pattern. i.e.:
grep user1 /etc/passwd /etc/group
will search for the "user1" in the passwd and group file.

Note I like to use the -i option so I do not have to work about the case when I am searching. Also the -r option will make it recursive form the "dot", that is the current working directory. i.e.
grep -i gmail.com -r .
This will show you all the emails using google mail in the current directory and sub directories.


groupadd  

Add a new group to system accounts.


groupdel  

Delete a group from system accounts.


groupmod  

Modify a current group in system accounts. Note, users are normally members of various groups.


grpck  

Consistency check for /etc/group file.


grub-install devicename  

This is similar to ybin -v.
It installs the multiboot GRUB bootloader on the PC. i.e:
grub-install hd0
grub-install fd0
grub-install /dev/sda

Notice that is sda not sda1. Using sda1 will give an error.


htpasswd /usr/local/etc/apache/.htpasswd-users jsmith  

The above is used in Apache to add the user Jane Smith to the .htpasswd-users file. Note, you do not want to put this under your normal public web root (URI space). Often the file will be called .htpasswd
If you add the -c option it will create a new password file. Be careful here as it will overwrite the old one.
htpasswd -c /home/doe/public_html/.htpasswd jane
Finally to delete a specific user;
htpasswd -D /home/doe/public_html/.htpasswd jane


http://localhost:631/printers  

Type this in Firefox or your favorite web browser to administer your printers under Darwin on a MAC. Note, this is pretty much identical to what you have in the Linux world. You can use this to clear the print queue, stop and start print jobs, add and delete printers. It is a good place to start for printer troubleshooting problems.


id  

This will tell you, who you are and which groups you belong to.
$ id
uid=1000(victor) gid=1000(victor) groups=1000(victor),4(adm),20(dialout),24(cdrom),46(plugdev),116(lpadmin),118(admin),124(sambashare)


ifconfig -a  

Shows your network configuration including IP Addresses for all interfaces including ethernet, wireless and dialup.
To define a network address without using DHCP type:
ifconfig eth0 192.168.1.12
note here eth0 is the interface followed by the IP address.


index.html or index.shtml  

This is the starting file for webpages for a Webserver. Typically for an Apache 2 server this will be at:
/Library/Webserver/Documents for the MAC OS X
/var/www for Ubuntu
/var/www/html for Mandriva
/srv/www/htdocs for Suse
/var/apache/htdocs for Solaris 10.0 from Sun


init 0  

Shut down Linux. This is also the equivalent of the "halt" command.


init 1  

Launch Linux in single user text mode.
Note, no network is present.


init 2  

Multiuser Text Mode with no Network Support.


init 3  

Launch Linux in multiuser text mode with network support.


init 4  

Launch graphical network X Windows Interface in Slackware. Equivalent of "init 5" in other Linuxes.


init 5  

Launch Graphical User interface with network support. Note, in Slackware this is done with "init 4".


init 6  

Restart Linux Server. This is also known as rebooting.


installgrub stage1 stage2 /dev/rdiskette  

On the Solaris platform, this is how you install the GRUB Solaris program. Note, it is different from the standard Linux/GNOME GRUB. I assumed here you were installing it on a floppy. You need to first do the following:

  1. fdformat -U floppy
  2. newfs /vol/dev/aliases/floppy0
  3. volcheck
  4. A GNOME GUI will come up allowing you to finish the formatting, pick DOS File System. Give it a label of solaris
  5. type in a terminal:
    cd /floppy/solaris
  6. mkdir /boot
  7. mkdir /boot/grub
  8. cp /boot/grub/stage* .
  9. cp /boot/grub/menu.lst .
  10. /etc/init.d/volmgt stop
    to unmount the floppy.
  11. cd /boot/grub
    to put you in the directory where the stage1 and stage2 original files reside.
  12. The last step is the installgrub command. If you are installing it to a hard drive instead of a floppy type the appropiate device name for the hard drive. i.e.
    installgrub stage1 stage2 /dev/rdsk/c0d0s0


installpkg -warn program.tgz  

Used to install a package in Slackware.


iostat  

On Solaris reports terminal, disk and tape input/output activity. Note, this includes NFS activity.


ip route add default via 192.168.1.1  

The above adds a route via a default gateway at the address of 192.168.1.1


k3b  

CD/DVD burner on the KDE desktop.


kdeinit  

Launch the KDE graphical display manager interface.


kill -9 ProcessID  

This command is often used in conjunction with the
top -u command. If you find a process that is consuming a huge amount of CPU you will use this command to stop the process. i.e.
kill -9 439
Here process 439 was the HPScanjet that did not close properly and was consuming 68% of the CPU.


kstat -n name  

On Solaris this will display the kernel statistics. It will give you the module, name, class, instance and relavant statistics. It defautls to all modules if you just type kstat alone. To narrow it down for a paricular module, i.e. the results from the icmp module used for pinging and routing packets type:
kstat -n icmp
You will see returned:
module: ip instance: 0
name: icmp class: mib2
crtime 23.815132327
inAddrMaskReps 0
inAddrMasks 0
....


less filename  

Similar to "cat" except you can use the pageup and pagedn keys to go forwards and backwards through the file. i.e.: " less menu.lst". To exit type "q" for quit.


ln -s symbolic_link_name  

For example, to create a path shortcut "tomcat" for where the tomcat files are installed on Centos, use:
ln -s apache-tomcat-5.5.23 tomcat
Note, the symbolic link name here is a directory.


locate filename  

Use this to find a file anywhere on your system. i.e.
locate rc.conf
This will find all the places this file used in bootup initialization of your system lives.

locate rc.conf
/etc/init/rc.conf


lockstat  

On Solaris this displays kernel locking and profiling statistics. Type
lockstat -H -D 10 Sleep 1
to see all the hold events denoted by the -H switch. Note only the top 10 events will be displayed for the type requested. This is denoted by the -D 10 switch. Note, the hold events here are the:

  1. Adaptive Mutex Hold
  2. Spin Lock Hold
  3. R/W Writer Hold
  4. R/W Reader Hold
See man pages for more details.This is only used for deep debugging.


logins  

Show users on a Solaris system.


lpr filename  

Print a file in Linux. i.e.: lpr menu.lst


lprm  

Remove all jobs from the Print Queue. You must be ROOT to do this.


lpstat  

Get info on the Print Queue status of jobs.


ls -A -al -lt  

List the directory structure. If you just want the name of the file or directory with no further information. You can do ls all by itself, that is with no parameters. I like to use the -lt to get the most recent files uploaded to a directory and then I can remove all the others with the rm * command, but be very careful doing this. The further information includes permissions, file size and symbolic links. Note adding the -A gives you the hidden files. To additionally get the inode number for a file and recursively list all the files in a directory add in iR as parameters. i.e.:
ls -AailR

To find the number of files in the current directory type:
ls -1 | wc -l
The dash one denotes a file and the dash l gives you the line count only as part of the wc (word count) command.

To find the number of files recursively in the current directory use this:
ls -l . -R | grep "^-" | awk '{print $5}' | wc -l
Notice, that is a dash l not dash one
Similarly you can find the number of files in any directory by typing:
ls -l [full directory path] -R | grep "^-" | awk '{print $5}' | wc -l

Note, you can not recursively use
ls -1 [full directory path] -R | wc -l
This is because it counts the current directory in there. Try it, if you do not believe me!


ls -i  

Get a listing of the inode numbers. i.e.
ls -i
2093069 *..`~?? 2750668 pulse-2L9K88eMlGn7

Notice the first file has a lot of special characters in it, but we can easily identify it by inode number. See the find and the stat commands please.


ls -lR | grep "^d" | awk '{print $9}'  

The above command will get a list of directories recursively. I started at the /etc/perl directory here:

root@victor-900HA:/etc/perl#
CPAN
Net
XML
SAX

Note your UNIX/Linux may put the directory name in a different column so you may have to change the print$9 to another number.
Note this does not give the full path to the directory just its name. To get the full path , just use the standard
find -type d
Note this command is automatically recrusive and assumes you are starting at the DOT current directory.


lsattr options files  

Print attributes of files on a Linux ext2 File System. Options:
-a List all files in specified directories.
-d List attributes of directories, not of contents.
-v List version of files.
-R List directories and their contents recursively.
For an ext3 file system use the ls command


lsmod  

lists what kernel modules are currently loaded in memory.


lsof  

lists all open file handles.


lspci  

lists all pci devices in the system.


lsusb options  

List all USB devices. Options:
-b Show IRQ and addresses as seen by the cards instead of the kernel.
-D device
Only show information about the specified device. This should be given as a file in the /proc/bus/usb directory, i.e.:
lsusb -D /proc/bus/usb/001/001
-t Print a tree showing connections between devices.
-v give verbose information.


lvm (logical volume manager commands)  

This is often used in conjunction with setting up RAID devices. Here are the basic commands:

lvcreate (Creates a new logical volume.)
lvdisplay (Displays logical volume information.)
lvextend (Extends a logical volume size.)
lvreduce (Reduces a logical volume size.)
lvremove (Removes a logical volume.)
pvcreate (Creates a physical volume.)
pvdisplay(Displays physical volume information.)
pvscan (Finds all existing physical volumes.)
vgchange (Activates/deactivates volume groups.)
vgcreate (Creates a volume group.)
vgdisplay (Displays volume group information.)
vgextend (Extends a volume group by one or more physical volumes.)
vgreduce (Reduces a volume group by one or more empty physical volumes.)
vgremove (Removes an empty volume group.)
vgscan (Scans for volume groups.)
For more details please click here.


mac-fdisk devicename  

This is the fdisk partition utiility for the MAC. It is used when putting Debian type Linuxes such as Ubuntu on the MAC. To start type:
mac-fdisk -l
This will give you a list of partitions.
mac-fdisk /dev/hda
will enable you to perform various operations on this device such as:
p to print the partition table
d to delete a partition.It will prompt you for the number.
b to create a Newworld Bootstrap partition to enable the MAC to multiboot with Linux/MAC OSX
w to write the partition map. This is similar to the MBR (Master Boot Record in MS Windows).


man command  

This displays the manual pages for a given command. i.e. "man cd"


md5sum filename  

This gives a check sum to verify a file has been downloaded as an exact match. For Example:
md5sum /home/victor/backup_10_30_09.gz
might return a hexadecimal number like 218730e7de6c59e892e1f1099908a42c


mdadm (Raid Device Manager)  

This is used for configuring RAID in Linux. Typically RAID1 is used on two physical disk drives to mirror each other. You can make it even better with RAID5, but this is best done with a hardware card. RAID1 is done through just software. Here is how you would create the RAID1 array assuming two disks of /dev/hda1 and /dev/hdb1:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hda1 missing
When you are done putting a file system on /dev/hda1 you can use this command to add in the mirrored disk drive:
mdadm --manage /dev/md0 --add /dev/hdb1
It will then start building the mirrored drive for you. Additionally it is nice to use lvm Logical Volume Manager to configure the RAID device. Note, all this can be done through the GUI interface when you install Edubuntu which uses the LTSP (Linux Terminal Server Project). The lvm talks to the /dev/md0 RAID device and drives can be added or subtracted through Logical Volume Manager.


mget  

Get multiple files from remote host via ftp file transfer. Please make sure prompt is set appropiately first to be in batch mode, so you are not continually prompted. Here is an example:
mget *.txt
to get all text files in a directory.


mkdir  

create a directory, i.e. "mkdir docs" . Note, this puts a directory called docs below the current directory you are now in.


mount device directory  

Make a filesystem available from a given device and put on a directory.
i.e.: "mount /dev/hda12 /mnt/data"
Note, this is the Windows FAT 32 partition.
You can also type mount all by itself to see the devices mounted:
mount
/dev/hda11 on / type ext3 (rw,noatime)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/hda12 on /mnt/data type vfat (rw)

For Ubuntu on a MAC type
mount /dev/sda9 -t hfsplus /media/Backups_mac
This assumes there is a firewire external drive on scsi device sda9.

To mount a DVD Movie type:
mount /dev/dvd /mnt/dvd
Make sure under /dev there is a "dvd" directory. This should automatically be there. You may have to create the "/mnt/dvd" directory.
To mount an NFS external file system:
mount -t nfs 192.168.0.2:/home/user1 /mnt/nfsdata

On Solaris this has a slightly different form. i.e.:
mount /dev/dsk/c0d0s7 /export/home
This is where the user directories are mounted. i.e.:
/export/home/victor
assuming he has an account here.


mpstat  

On Solaris report processor statistics for each CPU.


mput *  

Use this to put multiple files up there for an ftp file transfer. Here is an example:
mput *.JPG
will put all the Jpeg files up there. Note you must first turn off prompt mode
Search for the prompt command here.


mv filename1 filename2  

This is used for renaming files. i.e.: "mv index.html index.php" . Note, if index.php already exists it will be overwritten.


mysql (select commands)  

If you are totally unfamiliar here is a gentle introduction
Assume there is a table called bbc_table containing the fields of name, region, population, gdp where name donates the name of the country. Here are some examples:
select name, region, population from bbc_table
select name from bbc_table where population >= 200000000
select name, round(gdp/population,0) from bbc_table where region like "Asia"
select name, population from bbc_table where name in ("France", "Germany", "Netherlands")
select name from bbc_table where name like "%United%"

select * from bbc_table
(use this to display all fields)

Here is an example of nested selects:
List the name and region of countries in the regions containing 'India', 'Iran'.
select name,region from bbc_table where region in (select region from bbc_table where name in ("India", "Iran"))
To find all countries with a per capita income greater than or equal to United Kingdom in Europe:
select name, round(gdp/population,0) from bbc_table where region = "Europe" and gdp/population >= (select gdp/population from bbc_table where name = "United Kingdom")
Lastly to find all countries that had a bigger GDP than countries in Europe:
select name, gdp from bbc_table where gdp > ALL (Select gdp from bbc_table where region = "Europe")
The following refers to aggregate selects:
select distinct region from bbc_table
select sum(gdp) from bbc_table where region = "Africa"
select count(name) from bbc_table where area >= 10000000
select sum(population) from bbc_table where name in ("France", "Germany", "Spain")
select region, count(name) from bbc_table group by region
select region from bbc_table group by region having sum(population) >= 100000000
select id,title, yr from movie where title like "%Trek%" order by yr
The previous shows all "Star Trek" films sorted by year.


mysql -h host -u user -p  

This will log you into the mysql shell interface. i.e.:
mysql -h localhost -u victor -p
This assumes victor has been added as a user. Otherwise you can log in with the user being root. You will then have a mysql> prompt.


mysql -u username -p database_name < backup_db.sql  

This allows you to restore a database from a previous backup.Note, if it was a big database that you gzipped, the command would be:
gunzip < backup_db.sql.gz | mysql -u username -p database_name


mysql> create database dbname;  

Here is an example:
mysql> create database bikes_db;


mysql> alter table  

mysql>ALTER TABLE games ADD season VARCHAR(6);
You can then use the update command to modify the table:
UPDATE games SET season = 'summer' WHERE yr = 2004;
UPDATE games SET season = 'winter' WHERE yr = 2006;
If you want to remove the column season:
mysql>alter table games drop season;
SELECT * FROM games;


mysql> create index  

CREATE INDEX gamesIdx ON games(city,yr);
SELECT yr, city FROM games order by yr
This is especially useful for speeding up processing. This is equivalent to indexed by in the COBOL world.


mysql> create table  

CREATE TABLE games (yr INT NOT NULL PRIMARY KEY ,city VARCHAR(20) );
You can now use the insert command,as described earlier to stuff the table.
INSERT INTO games(yr,city) VALUES (2004,'Athens'); INSERT INTO games(yr,city) VALUES (2008,'Beijing');


mysql> create view  

CREATE VIEW old_games AS SELECT yr,city FROM games WHERE yr<2006;
You can now use this view like a normal select:
SELECT * FROM old_games;


mysql> delete command  

mysql>DELETE FROM games WHERE yr=2000;
The above will delete from the "games" talbe all records for the year 2000.


mysql> describe tablename;  

This provides the layout for the given table. i.e.:
mysql> describe jos_weblinks;


mysql> drop command  

for example:
mysql> drop database cars_db;
will remove the database of cars_db.
mysql>DROP VIEW old_games;
This will remove the view.
mysql>DROP INDEX gamesIdx ON games;
This will remove the index.
mysql>DROP TABLE games;
This will remove the table.


mysql> find duplicate records  

mysql>-- find duplicate id
select id, product, count(*) #_of_dups
from test_data
group by id, product
having count(*) > 1

The above is a portion of a transaction sql "t-sql" program to find records with duplicate keys. You can then use the delete function to remove them.


mysql> functions  

concatenation:
mysql>SELECT CONCAT(name, ' is in ', region) FROM bbc_table WHERE name LIKE 'D%'
This will show all countries that start with the letter D and what region they are in.
case statement:
mysql>SELECT title, score,
CASE WHEN score>8.5 THEN 'Excellent'
WHEN score> 5.5 then 'average'
ELSE 'lousy'
END
FROM movie WHERE 100 >id

The previous will display excellent, average or lousy depending on the value of "score" for the first 100 films in the database table.
substring extraction:
mysql>SELECT name, SUBSTRING(name FROM 1 FOR 2) FROM bbc_table WHERE region = 'Asia' This shows the first two letters of all the countries in Asia.
substring search:
mysql>SELECT name, SUBSTRING(name FROM 1 FOR POSITION(' ' IN name)) FROM bbc_table WHERE name LIKE '% %'
This will give the first word in the name of the country, i.e. United for "United Kingdom".
lower or upper casing:
mysql>SELECT LOWER(name) FROM bbc_table WHERE UPPER(region)='SOUTH AMERICA'
replace null entries with a value:
mysql>SELECT party_code, party_name, COALESCE(leader, 'NO LEADER RECORDED!') FROM party
The previous will replace all political parties that have "NULL" as the leader with the phrase "NO LEADER RECORDED".
current date/timestamp:
mysql>SELECT CURRENT_TIMESTAMP, CURRENT_DATE, CURRENT_TIME FROM nix
Note nix (nothing in German) is a built in table giving you this information.


mysql> grant privileges for a user to access database  

for example:
mysql> grant all on bikes_db.* to victor@localhost identified by 'mysql_password';
This will allow victor on the client host of localhost to access this database.


mysql> insert command  

mysql> INSERT INTO games(yr,city) VALUES (2012,'London');
The above inserts a record into the "games" table mentioned in the select commands.


mysql> meta data info  

mysql>show tables
This will display all the tables in the database.
mysql>show columns from bbc_table
This will display all columns in the table.
mysql>select * from bbc_table limit 10
This will display the first 10 records in the table.
mysql>select * from bbc_table
order by population desc
limit 11,10

The previous will get records 11- 20 when sorted in descending order by population.
mysql>select version()
This will display the mysql version.


mysql> select join commands  

Here is an example using the JOIN command. There are two tables "ttws" and the "games" table. The table "games" shows which city the championships were held in. The Women's Single's winners are in the table "ttws". This will show who won medals in Barcelona, what country they are from, and what kind of medal they won:
select who, ttws.country, color from ttws join games on (ttws.games=games.yr) where games.city = 'Barcelona'
This is also known as an inner join
Suppose we have two tables, one containing all the 129 members of the Scotish Parliament ("msp") and another table ("party") containing the party code, name of the party and the leader of the party consisting of 9 rows. Note, some members of parliament can belong to no party. To obtain a list of all the parliament members by name, and "party name" where available type:
SELECT msp.name, party.name FROM msp LEFT JOIN party ON (msp.party = party.code) order by msp.name
This is also called a left outer join
To find all members who belong to no party type:
SELECT msp.name, party.name FROM msp LEFT JOIN party ON (msp.party = party.code) where party.name is null
To obtain a list of all the parties with one or more members type:
select distinct party.name from party right join msp on (party.code = msp.party) where msp.name is not null
This is also known as a right outer join
For a more detailed explanation on inner joins, left outer joins, right outer joins and self joins, please see:
here
Many thanks to the The Disenchanted Developer, (c) Melonfire 2003 for providing this. This person chooses to remain anonymous.


mysql> SELECT statement with LIMIT  

In this syntax: The offset specifies the offset of the first row to return. The offset of the first row is 0, not 1. The row_count specifies the maximum number of rows to return. The following picture illustrates the LIMIT clause. When you use the LIMIT clause with one argument, MySQL will use this argument to determine the maximum number of rows to return from the first row of the result set.


mysql> show create table tablename;  

This is a very powerful command. It will generate all the mysql code for you to create an existing table. i.e.
show create table finance_table;
Note, the first three lines of the table generating code should be something like:
use finance_db;
drop table `finance_table`;
CREATE TABLE `finance_table` (
This would be followed by a definition of all the columns in the table. When you generate the code it does not automatically give you the first two lines above, you must type them in. It gives you everything from the create table on.


mysql> show databases;  

This will show you all the MySQL databases.


mysql> source filename.sql  

mysql>source create_finance_table.sql;
This will create a finance table using the mysql command file. Note, the file must exist in the directory that you logged into when you went into mysql. Otherwise you must designate it by path in front of the file name.


mysql> update command  

mysql> UPDATE games SET city='Paris' WHERE yr = 2012;
The above updates/modifies and existing record in the "games" table.


mysql> use database;  

mysql> use bikes_db;
This is used for selecting the database you work with.


mysqldump -u username -h localhost -p database_name > backup_db.sql  

This allows you to back up a database at the mysql> command prompt.
mysqldump -u username -h localhost -p database_name | gzip -9 > backup_db.sql.gz
This backs up the database and first gzips it, in case it is very big. Note, you can also run this as a cron job. In that case use this command:
mysqldump -u username -h localhost database_name | gzip -9 > db_backup_`date +"%Y%m%d"`.sql.gz
Notice, you leave off the -p option. You need to store the password in a file called .my.cnf , that is two dots in there in the ~ that is home directory. You need to do a
chmod 600 .my.cnf to make it secure. Here is the file:

[mysqldump]
user = dbusername
password = dontask-donttell

Never put a password directly in a cron job as it will go into the log file and your are in trouble then.

mysqldump -u username -h localhost --all-databases | gzip -9 > db_backup_ALL_`date +"%Y%m%d"`db.sql.gz
This will do it for all your databases.


mysqlimport -u username -p password database_name backup_db.sql  

To restore a database that already exists use the above command.


named  

This is the service (daemon) that initiates the domain name server. The config file is usually at
/etc/named.conf


nautilus-cd-burner  

CD/DVD Burner on Gnome Desktop, see "CD/DVD Creator". This is the command line way of invoking this program.


ndd  

On Solaris this is used to set and get driver configuration parameters for the kernel. i.e.:
ndd /dev/ip \?
This will show all IP variables to set in the kernel.
ndd /dev/ip ip_forwarding 1
This turns on packet forwarding for the kernel.


netstat -a  

Display Network Socket Connections for all sockets.


netstat -r  

Display Routing table.


newfs devicename  

On Solaris type:
newfs /dev/dsk/c0d0s5
to put a new file system on slice 5 (partition 5) of the first hard disk. For a floppy type:
newfs /vol/dev/aliases/floppy0


nfs-kernel-server  

This is the Ubuntu NFS Server (network file services) which runs in kernel space. To launch or reset type:
nfs-kernel-server restart It uses the etc/exports file to determine which paths are exported. It lives in the directory of
/etc/init.d


nfsstat  

Show NFS (Network File System) statistics.


nmap  

used for security/debugging of port problems. i.e.
nmap -sU -sT 127.0.0.1
This will scan all TCP and UDP ports for this host showing which ones are being used. Note, I have chosen the loopback host, that is your machine. Most companies block this for users outside their network that are not ROOT.
If you just want to see if a host is up and talking DHCP do
nmap -p T:67,68 10.11.22.0/24 > 10_11_22_HOSTS.txt

Above network numbers were made up. You can change what portion you view with the /xx option. It can be 8 , 16, 24, 48 etc.


nslookup domain  

This retrieves the information from the domain name server for a given domain. It is similar to dig i.e:
nslookup converttolinux.com
Server: dslmodem.domain.actdsltmp
Address: 192.168.0.1

Non-authoritative answer:
Name: converttolinux.com
Address: 208.101.48.172


pdisk devicename -dump  

This is similar to the fdisk and mac-fdisk command for setting up partitions. This is used on the MAC OSX native UNIX. Here is an example to show the first hard disk partition map:
pdisk /dev/disk0 -dump
/dev/disk0 map block size=512
Partition #: type name length base ( size )
1: Apple_partition_map Apple 63 @ 1
2: Apple_UNIX_SVR2 swap 1048577 @ 64 (512.0M)
3: Apple_HFS MAC 100608968 @ 16622432 ( 48.0G)
4: Apple_Bootstrap bootstrap 1600 @ 1048641 ( .8M)
5: Apple_UNIX_SVR2 untitled 15572191 @ 1050241 ( 7.4G)
6: Apple_Free Extra 8 @ 117231400
Device block size=512, Number of Blocks=117231408 DeviceType=0x0, DeviceId=0x0


perl  

See my webpage for explanation of perl. Click here


pfiles pid  

On Solaris show open file descriptors for a process ID. i.e.
pfiles 8587
will show the open file descriptors for the tcsh process which happens to have this pid number of 8587.


ping Server  

Test reachability of an IP Address. i.e. : ping www.converttolinux.com


pkgadd  

Add a package on Solaris. i.e.
pkgadd -d /cdrom/Solaris_i386/Packages
This will add the packages on the cdrom device.


pkginfo  

Query a Solaris Package.


pkgrm  

Remove a package on Solaris.


pkill -n processname  

On Solaris kill a process by name. i.e.:
pkill -n gnome-terminal
This will kill and exit your current terminal session.


pldd pid  

Display a list of dynamic libraries in use by a given process. i.e.
pldd 8587
will display the libraries used by the tcsh process which has this pid number.


pmap -x processid  

This is a Solaris command which gives you information about the address space of a process. i.e.:
ps -ef | grep tcsh
root 8587 2052 0 14:00:19 pts/3 0:00 tcsh
pmap -x 8587
will tell you what address space the tcsh process is using.


portmap  

This is a service used in NFS (Network File Systems). To invoke type:
portmap restart
This is normally automatically done by issuing the command
nfs-kernel-server restart


prompt  

This command toggles the mode for prompt from interactive to non interactive when doing ftp file transfers
You need it to be in non interactive, that is batch mode when transfering. If you keep getting question mark prompts you are in the incorrect mode.


prstat -a  

This is a Solaris command which works like top -u but gives you more detail.


prtconf  

Display configuration info on a Solaris system.


prtvtoc /dev/dsk/c0d0s0  

Show disk partition information on Solaris. Like "fdisk -l" in Linux.


ps  

show status of processes. This is often used in combination with "grep" to see if a service is loaded. i.e.:
ps -ef | grep nfsd
will show that the NFS Daemon is running. A more advanced form is: /usr/ucb/ps –axuww | grep –i .xml
This will show all the processes calling a .xml file.


pstack pid  

On Solaris see the process call stack for a given process ID. i.e:
pstack 8587
will show the process call stack for the tcsh process. Note, you have to first use grep to find the process ID you want to look at.


pstree  

Displays processes in a tree format, showing processes in order of initiation and each of their children. This is great for seeing how your system has booted up.


ptree  

This is the Solaris version of pstree on Linux. Note, it gives you a little more detail than the Linux command.


pump  

Show DHCP information on Linux.


put filename  

Used to place files on an FTP or Web Server. i.e. "put install.txt" . Note, wildcards can also be used here. i.e.: "put *.txt" will place all text files on the Server.


pwck  

Consistency check for the /etc/passwd file. Warning, do not delete this file.


pwd  

Print Working Directory , This tells you what directory you are in. The default directory is /home/user on most systems.


rails blog -d mysql  

Launch Ruby on Rails. This creates the application blog under a directory of /var/www/myapp/blog Note, this creates a development version using mysql for the database.


reboot  

restart the system.


removepkg program.tgz  

Remove a package in Slackware.


restore  

Used to retrieve files from backsups made with the dump command. i.e: newfs /dev/dsk/c0d0s5
fsck /dev/dsk/c0d0s5
mount /dev/dsk/c0d0s5 /mnt
restore rf /dev/mnt/1
This assumes a tape file on device "/dev/mnt/1" is being restored to the device "/dev/dsk/c0d0s5" (the fifth partition of the first disk).A file system check is done before mounting the new file system.


rm filename_or_directory  

Removes a file. Use this with extreme caution. i.e.: rm linux.doc
rm -Rf ./zen-cart_1.06/
This will remove the directory recursively. Use with caution.


route  

Displays routing table , same as "netstat -r".


route add  

Add a route with appropiate info. i.e. : "route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0"
This adds a route to the network 192.56.76.x via "eth0" (ethernet interface 0). The Class C netmask modifier is not really necessary here because 192.* is a Class C IP address. The word "dev" can be omitted here. Second i.e.: "route add default gw mango-gw"
This adds a default gateway called mango-gw.


route del  

Delete info from routing table. i.e: "route del default gw mango-gw"
This deletes the default gateway mango-gw.


rpm -i program.rpm  

Install Red Hat Package. Use "rpm -u" for Update. Use "rpm -e" to erase a program.


rpm2tgz package.rpm  

Used in Slackware to convert a package from rpm (Redhat format) to .tgz format for installation. The Slackware program will be called package.tgz


rsync -a /directory1/ /directory2  

This will copy a source directory to a destination directory and synchronize any changes in the directories contents. i.e:
rsync -a ./system/ /home/salv/.local/share/evolution/calendar/system/

The previous synchronizes my Evolution Calendar on two different Linuxes on my netbook from Pear Linunx OS8 to Fedora 21. You have to reboot to see the changes take effect or logout and log back in. Notice, I did not use the -delete option.
For an exact copy use:
rsync -a --delete /directory1/ /directory2
To use for a remote host type:
rsync -a -e ssh Documents/ user1@192.168.0.2:/home/user1/Documents
This synchronizes directoried between my Apple OSX host and my remote Linux Suse machine.


scp -P 1234 user@abclife.com:*.gz .  

secure copy, use when going across a network for a sensitive file. Note, the port 1234 is made up, you must find out the real port from your administrator. This is based on ssh keys. In this case we are copying down some zipped tar files in the root directory on the remove host. Typically, this would be a backup.


sdiff  

This command compares two files and merges the output interactively. To see the common elements between file_a and file_b use the following:
sdiff --left-column file_a file_b | grep \(
The elements that are in common will have a left parantheses as the last character. Consult the man pages for more details.


sed 'list of editing commands' filename > newfilename  

This is the stream editor, it uses the same commands as vi but can do them on a bunch of files. Here is one example, suppose you wanted to change all instances of
"converttolinux.com/index.html" to "localhost/index.html"
This would be used for testing your webpage on your localhost HTTP Webserver. Simply type:
sed 's/converttolinux.com/localhost/g' printer.html > new_printer.html
Note, this does it for only one file. To do it for a bunch of files we can put it in a Perl script. See my example under the Perl link on my web page.


sftp  

Secure File Transfer Protocol.Same as ftp but data is encrypted.


share  

Make a file system available over the network. Used with NFS (Network File System) This is only for Solaris systems.


smbpasswd -a username  

create the user account normally, i.e.
user add victor
Then type:
smbpasswd -a victor
This adds the account to the Samba user database and then sets the password for it.


smbstatus  

Display connection statistics for Samba Server, i.e.:
Samba version 3.0.22
PID Username Group Machine
-------------------------------------------------------------------
5815 victor users victor-odlivaks (192.168.0.3)
5513 victor users victor-odlivaks (192.168.0.3)

Service pid machine Connected at
-------------------------------------------------------
profiles 5513 victor-odlivaks Fri Nov 10 08:52:22 2006
profiles 5815 victor-odlivaks Fri Nov 10 09:03:20 2006

No locked files


source filename arguments  

This is used to execute a shell script file. i.e.
source startupscript
Note, this is the equivalent to typing
./starrtupscript
if you are in the directory. In this case no parameters were passed to the file.


stat [file or directory name]  

stat /tmp
File: `/tmp'
Size: 12288 Blocks: 24 IO Block: 4096 directory
Device: 802h/2050d Inode: 2093057 Links: 15
Access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-04-24 15:24:59.532820239 -0700
Modify: 2013-04-24 15:17:01.842451511 -0700
Change: 2013-04-24 15:17:01.842451511 -0700
Birth: -

Use this to get the inode and other great metadata about a file or directory. Notice Birth is never kept track of for a file.


stty -a  

This command will show the terminal setting characteristics. It tells which characters signal the end of line (eol), interrupt (intr), the erase character (erase) etc.


su  

Used to log on as ROOT user on UNIX/LINUX system. This user does all the Admin. Use cautiously. You will be prompted for a password after typing this. This is similar to the "Administrator" login of Windows XP.


sudo  

A lot of systems do not give you ROOT privileges for protection. Instead you get privilege to run certain ROOT (su) type commands. This is the case with Ubuntu. In a file called /etc/sudousers these privileges are defined. Here is an example assuming privileges "sudo" users could add or modify users but not delete them.This is in the sudousers file.
User_Alias PRIVUSERS = raki, shanti
Cmnd_Alias USERADMIN = /usr/sbin/useradd , /usr/sbin/usermod
PRIVUSERS ALL = USERADMIN
Finally the command user shanti would isuue is:
sudo useradd cchaplin
Note, it is assumed "/usr/sbin/" is in the path so typing "useradd" is sufficient.


svnadmin action file  

This is used by the Subversion content management system.
svnadmin dump /var/svn/yoga > yoga.svn
will create a dump of the database. Conversely:
svnadmin load /var/svn/yoga < yoga.svn
will load a new version of the database. Lastly use
svnadmin create /var/svn/yoga to create the repository. Note, always use the svnadmin tool to manage what is in the repository. Do not directly copy any files in there. For more info see the help pages.


tar cvf tarfilename directory  

Make a backup of a directory. tar originally meant Tape Archive. i.e.: "tar cvf email.tar email" . This takes all the files in the email directory and puts them in a tarball called email.tar.
Here is another daily backup using tar and gzipping it:
tar -czf backup_`date +"%Y%m%d"`.tar.gz /home/victor/
Note, I used the home directory ~ here.
It takes longer, but it is always better to gzip it using the z switch. Enjoy!


tar xvf tarfilename directory  

This is the restore function of tar. i.e.: " tar xvf email.tar email" . This will restore the tarball email.tar to the directory email. Note, the email directory will be overwritten if it exists. Files can also be zipped, that is with a .gz extension. In this case use:
tar -xzvf /home/victor/Joomla_1.0.12-Stable-Full_Package.tar.gz
Note, you want to be in the directory you are going to untar to.


tcpdump  

Show TCP IP Packets for network trace. This is a very powerful tool. Here is one example:
tcpdump -nlxs 1500 -w tcpdump.out port 22 and host converttolinux.com
This monitors the SSH Port 22 capturing packets of up to 1500 bytes in length with the data as hexadecimal bytes denoted by the -x switch. The -n disables nslookup so we get the IP address instead of the host name. All of the tcpdump output is saved in the file called tcpdump.out using the -w switch to write the output to a file. The -l switch means the output is buffered a line at a time. I would use this to troubleshoot uploading files via secure FTP to my web server. For a further enhancement to this please see the last paragraph of my Perl Page


tcsh  

This is a C shell with file name tab completion and command line editing. Normally in a shell, i.e.:
ksh , sh , bash, csh
You have history built in by using the up and down arrow key to scroll through your previous entry. Also if you just start to type a filename and hit the tab key it will complete it for you. If you find yourself without these features just invoke the shell above by typing
tcsh
With the default install on Solaris 10.0 you must use this.


top -u  

Show system usage statistics including CPU and memory usage for processes. The UNIX command and the PID (process ID) are included. The -u causes the highest usage to be displayed at the top of the list. Here is how to use it to quickly search for a process you want to kill that is hogging memory:
top -u -l1 20 | grep HPscanjet

Note the -l1 means log the result to a file or stadnard output after one cycle of the top command. The 20 denotes to only report the first 20 entries. This output is then piped to standard output and searched with the grep command for the offending memory hog, which is the HPscanjet program. Knowing this we can then use the kill -9 xxx command where xxx is the Process ID (PID) number.


touch filename  

This is used to give a file the current date and time stamp. If the file does not exist it will be created with zero bytes.
touch logfile.log
You can also create a file with today's date attached with:
touch myfile_`date +"%Y%m%d"`
This is used alot with mysqldump and tar commands.


tr "[:upper:]" "[:lower:]"  

This is used to translate upper to lowercase for a file stream. It is typically used like this:
cat recommend_yoga.txt | tr "[:upper:]" "[:lower:]" > recommend_lc_yoga.txt
Notice that I got a new name for converted file. Similarly you can do this using:
cat recommend_yoga.txt | tr "[:lower:]" "[:upper:]" > recommend_uc_yoga.txt


traceroute Address  

Get path to a Server or IP Address showing all the routers and gateways inbetween. i.e.: traceroute www.linux.org


tripwire  

detect and report file system change.


truss  

On Solaris this is used to executes a specified command and produces a trace of the system calls it performs, the signals it receives, and the possible machine faults it may incur. Here is a simple example type:
truss whoami
to see all that is involved in this simple request.


ufsdump  

Solaris version of command for backing up File System. i.e:
ufsdump 0f /dev/st0 /
This will backup all files from the ROOT directory to the tape device "/dev/st0"


ufsrestore  

This is the Solaris version of restore. The command line parameters are identical to the restore used in the Linux world.


umount /media  

This is the command for unmounting a partition attached to a directory.I noticed that in Fedora sometimes the partitions could not be seen on a multiboot system. Do the command:
umount /media
The various partitions will then begin showing up. Do it once for each partition that you do not see. Then type mount all by itself and you should see each partition appear. You can also click on the dolphin file box


uname -a  

Display UNIX/Linux version. The above on my MAC gives:
Darwin Victor-Odlivaks-Computer.local. 6.8 Darwin Kernel Version 6.8: Wed Sep 10 15:20:55 PDT 2003; root:xnu/xnu-344.49.obj~2/RELEASE_PPC Power Macintosh powerpc


unshare  

Used with Solaris to make a shared file system no longer available. i.e.:
unshare /docs


up2date package_name  

On Centos use this to install packages. It is similar to the apt-get command in the Debian/Ubuntu distributions. i.e.
up2date exim
This will install the exim MTA (Mail Transport Agent).


update-grub  

update-grub, update-grub2 - stub for running grub2-mkconfig
It is the same as running this in the command line:
grub2-mkconfig -o /boot/grub2/grub.cfg
Note, you may have to edit the file it creates if not all vmlinux and initrd kernels are found. Also make sure that the grub is installed on this particular partition. That is if you update-grub, but you do not boot from this partition, you still will not be able to boot into any new Linux you just installed.


upgradepkg program.tgz  

Upgrade a package in Slackware.


urpmi -i package  

Used in Mandriva to install a package. i.e.: urpmi -i firefox


useradd username  

Add a user account. Here is the full text in Solaris:
useradd -d /export/home/victor -m -s /usr/bin/tcsh -c "Victor Odlivak" victor
Note the -d switch creates the home directory and the -m switch copies the the appropiate files to it. The -s switch is used to chose your shell. Consult man pages for more info.


userdel username  

Delete a user account.


usermod username  

modify a usernames account


vi filename  

This is the Visual Editor that originally came with UNIX. If you type
i (enter insert mode and begin typing text)
Hit ESC key (exit insert mode and return to command mode)
type : (in command mode to enter a command)
Here is one of my most used commands, the global replace with prompting to make sure each replace is ok.
:g/text/s//replacetext/c
Use a y carriage return to ok each replacement
You can also use control characters in the text field for a global replacement. To do this hold down the ctrl key and the letter v at the same time. You will then see a ^ carrot symbol. Then type the carriage return. You will then see ^M. Note, this is NOT the same as typing a carrot symbol and then the M. So here is the final command to globally remove all carriage returns from a file. Unix does not use them.
:g/^M/s///

lastly type
:wq (in command mode to write the file and quit.

Undoing, Redoing, Retrieving Commands:
u (Undo last change)
U (Restore Current Line)
. (Repeat last change)
"hp (Retrieve one of last 9 deletes; h is a hidden register numbered 1 thorugh 9, retrieved in reverse order.) i.e.:
"2p will put back what you did in the next to the last delete.

Copying and Pasting Data:
nY (Yanks a copy of n or more lines from the cursor position into the register.) i.e.:
10Y (will grab 10 lines from where the cursor is positioned. This is also known as yanking).
P (This will paste in, also known as put, what you just yanked.)
There are many more commands, but this should get you going.


vim filename  

This is the improved VI. It has a lot more help and does completion of file names for you when in the command line. It also fixes a common bug on laptops where the carriage return is not recognized. This occurs in Ubuntu and Solaris for me. So I just type vim on these systems instead of vi.


vmstat  

Reports information about processes, paging, block IO, traps, kernel threads, virtual memory and cpu activity. This is similar to:
top -u
On Solaris type:
vmstat -p
For info on CPU type:
vmstat cpu 5
This will display the CPU statistics every 5 seconds.


volcheck  

Used to mount a floppy in Solaris. Note, the vold daemon must be running. This is done by starting the volmgt program in /etc/init.d/ See volmgt command for more info.


volcopy  

image backup tool for Solaris. i.e.:
volcopy -F ufs /export/home /dev/rdsk/c0t0d0s3 - /dev/rdsk/c0t0d1s3
will copy the /export/home file system from one physical disk to the second (d1) physical disk. Note, the system is put in the same partition (slice) s3.


volmgt  

Program which controls volume management in Solaris for removable media such as CD/DVDs, floppies, USB devices and firewire devices. It lives in the directory:
/etc/init.d/
You can start it by typing in its directory:
volmgt start
or to stop it type:
volmgt stop
It invokes the service (daemon) vold which will be listed as a process. Once it is running you can type volcheck
to automatically mount a floppy.


webmin  

Used in Mandriva for configuring Servers using a very nice built in GUI. It uses port 10000 on your localhost Apache webserver. It is automatically installed by Mandriva. It works similar to yast2 on Suse.


wget [webaddress]  

wget -r ftp://username:password@abc.def.org/\/go/to/desired_directory/*

I especially like using this command in combination with ftp to log you into a site. If you specify no directory you will be at your home directory and fetch all files recursively. If you want to specify a directory you probably have to put the backslash character in front of it, as I did here. This is one of my most favorite commands! Especially as a web master for several web sites.


whereis filename  

This is similar to the longer find command but a lot easier to use. i.e.:
whereis index.shtml
It will automatically search all directories you are permited to look at.


wman  

Used in Knoppix and Feather Linux as the man pages to keep distros small. The search is done via a web connection. i.e.:
wman stty


xinit  

Launch the X Windows display manager. This is the equivalent of "init 5" on some Linux systems.


xserver-xorg-video-intel  

Install this package and run it for laptops where you are having resolution or display problems. This comes about because the installer built into Ubuntu can install the wrong video driver. See this.


yast2 (Control Center)  

This is the GUI configuration tool on Suse. You can get to it from the Control Center menu or by typing yast2 at a root prompt. It is used for configuring your Servers and Services. It is similar to webmin on Mandriva , but does not use localhost.


ybin -v  

Install yaboot multiboot program on the MAC to boot with Linux/MAC. This is similar to the GRUB multibooter on the PC intel 386 chip. The config file is stored in /etc/yaboot.conf and is very similar to /etc/grub.conf used on the PC.


youtube-dl 'URL to file location on Web'  

Note, if you just do this with no parameters. You may get a lot more than is necessary. As an amateur musician, I do not need to see the players but hearing them is enough so I go for
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=R_ld62q9qfk
Note, this is a lot smaller than the .mp4 file for watching videos. But even with this, manifest still wants to download more than a straight .mp3 audio file, but it should be half to one quarter the size. Good Luck!!! Bright Moments!

Distros our always behind latest version of youtube-dl
Remove current version and reinstall from scratch with at the root prompt:
apt-get remove youtube-dl
wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl
hash -r
apt-get install python-is-python3

You need the previous line to make sure it can find python when you update.
Update anytime now with the command:
youtube-dl -U


yum install package  

This is used by Redhat, Fedora Core, Centos and Yellow Dog Linux to install packages.Here is an example from Centos:
yum install rpm-build gcc-java