Sun, 25/Feb/2018 12:29

This really began for my own reference so that I don't have to look up commands and functions. I passed the list on to my brother-in-law and thought I should post it here as well. The information below is provided as a help to newbies. Do not take my definition as the the absolute definition for anything. An internet search engine is a good friend, use one to find out or use the man pages. Learn all you can before using any command. Take responsibility for your actions. Our country needs more people willing to take responsibility for their own actions instead of blaming others and turning to the lawyers to sue over their own stupidity. Do not blame me if anything goes wrong.

Below are some common terminal commands (aka "command line" or "shell") for running in a Linux terminal. A bash shell is a type of terminal, perhaps it is the standard command line in linux. There are other shells that have difference commands and there are many that are based on the bash shell. I am typing this from a computer running Arch Linux which is a unique disribution (or distro for short). I like Arch, it has a good feel and idea to it. Not really a good first distro though. is a good place to find and read about which linux distros.

Terminal Helps

In general, commands are followed by a "--" or a "-" for options. like mycommand --dosomethingdifferent. most of the time you can type command --help to see brief help description of the particular command.
Note that the command line in linux, unlike DOS, is VERY case sensistive.
Also, note that linux, unlike windoze, does not need a suffix like ".doc" or ".html" to determine what something is. It treats everything the same (files, folders, directories, hard drives, thumb drives, network drives, etc). Each file (or folder, etc) contains a little piece of info in side the very first couple bytes of info that describe it. If you are writing a shell script usually you will put " #!/bin/bash" on the very first line of text. That is also partly why there are no "c" drives in linux. It drives me nuts when someone says "where is my 'a' drive" when they dont even know what that means. Everything in linux is listed under root (simply "/"). A drive can be mounted as /home/mystuff and another be /home/otherJunk and they can be completely separate physical hard drives or just separate folders on the same drive. They are treated seamlessly.
You may also often read about root. root is the user with all permissions somewhat like, I hesitate to say this, administrator in XP. If you are not root and you want to do stuff as root see su below or use sudo for a single command.

Some commands that I use often

man -- stands for manual. if you don't know what 'whichis' does you can type in man whichis and it pulls up an instruction manual for the command. use arrow keys to navigate and q to quit.

su --allows you to login in at the terminal as root and it assumes you know what you are doing and accordingly lets you do anything. aka be " super user". Some commands are only available for use to su. sudo is similar and will let you run a command as another user. This can be used instead of logging into root via su. so something like 'sudo make install' will ask you for the user/pass and run that as a separate user.

clear --clears command line

history --shows history of commands typed. "history -c" will clear the history. although, I prefer not to clear it.

sh -- runs a shell script that does not have execution permissions.

ssh --runs secure shell through which you can log into servers, email servers and other compters. Do not use "telnet" for anything that is private as it is VERY unsecure and transmitts everything, including passwords, in plain text.

ifconfig --depending on your version of linux this may only be available to root. it is very similar to the windows command ipconfig letting you see network connections and the like

hostname --shows the name localhost (that is the name of your computer inside your pc...always is localhost and also in various formats your PC uses to talk to the outside world.

uname -- show info about your system. "uname -a" shows linux distro.

ping -- Oh ya! you get to ping people...This is like reaching through the internet and tapping you on the shoulder without you knowing you got tapped.

traceroute --lets you trace a route (what path via internet) from your pc to another one on the network.

nmap -- probes open ports on a computer. HANDY! not always available (not installed or only to root). try nmap

whois --gives you info on PCs on other end of network

whereis --finds stuff on your pc for you. very handy!

find --also finds stuff. another variant is locate. locate is more thorough.

cd ---change directory. similar but not the same as windows version. "cd .." moves you up one directory. "cd ~" move you to your home directory, whatever that is defined for the specific user you are using. "cd /" moves you to the root of all.

ls --list contents of local directory. Similar to but not equivalent to "dir" in windoze.

mkdir, rmdir --make and remove directories respectively. make sure you have permissions to do it or it will not let you.

rm --remove file.

cp --copy

cat --concantenate contents of file to screen....aka display file contents on screen.

chown, chgrp ---change owner or grp of particular file or directory.

chmod --change permissions on file or directory, etc. read up on this one!

set --change shell parameters like the way the prompt looks, what is your home or default directory, and loads of other things.

exit --exits. If you have used the su command it exits super user mode and leaves you in the shell. Same as Ctrl-D.

the arrow keys -- they let you navigate through command history.

ps --lists running processes. Full list is found by "ps -A". You can also use "top" for a nice looking list of all processes. htop is like top but bettter depending on your purpose. For both top and htop q is for quit.

kill --oh yeah! this will kill any program running. If you type "kill 1293" that will ask process #1293 (# gotten by using the ps command above) to kill itself. Well, some programs will kill themselves and be "clean" about it. other's are stuck and will not even hear the request. so "kill -9 1293" will take a star wars blaster to #1293's head and shoot right through the program but it can leave stuff in memory sometimes. Of course, only if you have the right permissions.

grep --VERY important, complicated yet oh so easy. i dont know how to describe this one so look it up or see the pipe "|" description below for usage.

nano --a very useful little editor. Ctrl-X is for exit and you can then choose to save. most systems will have nano or pico by default. use it like "nano /home/somewhere/somefile" to edit somefile. or "nano /etc/rc.conf".

vim, emacs, vi ---are text editors. They are "interesting" to use. Read up on them first. They can be tricky the first few times but acceptionally handy once you figure them out.

mc --midnight commander. Is a file browser that is very handy, there are loads of different versions of it. You may not need it but it can come in handy.

date --show date

cal --show a nice calendar.

>>, <<, >, < --routing commands. For example if you want to output of one command to file. use "mycommand >>mystuffFILE" to append to the file or "mycommand >mystuffFILE" to overwrite it. very cool and handy!!!!!!!!!

df -- shows all drives currently mounted. oh so handy. du estimates the user file space usage.

mount, umount --mount and unmount drives. If a drive or partition is listed in the fstab file (/etc/fstab) with a mounting directory, you can type "mount mountingdirectory".

watch --this sets up program to watch the output of a command at given intervals.

nohup --means "no hangups" you can use this to run a command in the background without hang ups. meaning it is not a child process. output from the command will by defualt go to the file /nohup.out if you have permissions to write to the file. so something like "nohup mycommand" will run mycommand in background.

& --say you want to run a script file while you do other things. but it takes a long time. you can type "sh myscript &" and it will spawn off and run as a separate, child process.
a note about processes and children. if you say run firefox it is run as a process and will be a child of your desktop. if you kill the desktop (the parent of firefox) you will also kill all of its children. so inside firefox you can run a music thingy to listen to music inside firefox, if firefox dies so will the music. etc.

several important shortcuts and bits of info

autocomplete: when typing a command or filename or directory or whatever hit the "tab" key and it will perform an autocomplete. If there are multiple things that start with the same charcters it will complete as far as they are the same. Example: you are typing "ls /home/selfuser/m" and you hit the tab key and it completes up to "myfile" because there are myfile100, myfile2000, and myfile30000000 in the directory, hit the next letter and then tab again and it will finsih autocompleting.

More simple than cut/paste. Highlight something with your mouse and then at the commandline (or where ever really), click the wheel button or the lef tand right buttons simultaneously. It copies and pastes. if you hold down the Control button when you click it will paste and execute.

The "./" feature is important. say you have created a script file called "dostuff" and you want to run it. If you just type dostuff at the prompt it will probably not find it and run it even if you are in the same directory but if you type "./dostuff" it will look only in the local directory. Another example: if you are trying to get from your current directory to one inside it call "branflakes" you can simply type: 'cd ./branflakes' or 'cd branflakes' to get there.

* is a wildcard. Say i want to find all files with "myself" somewhere in the name. "locate *myself*" will work for that.

| is called a pipe as it pipes the output from one command to the input of another command. "ps -A | grep boinc" will show a list of all processes that have "boinc" in the name somewhere. "| more" is nice if you are trying to read a file from command line that is long. type "cat myfile | more" and it will let you scroll through it.

if then else elseif fi -- if statements start with if "some stuff" then. then you can have else or an elseif (aka else if) and to end is if backwards... fi.

loops are possible in script files in linux. look them up. for loops are cool. like if you want to read every file in a directory and do something to each one like you have a folder of JPG images and you want to change each to a TIF image file. try something like this:
for X in *.jpg;
do convert -t tif $X;

save this as myconverter then set permissions to be executable (chmod +x ./myconverter, if you are in the same directory). just run it by calling it as "./myconverter". if you do not set the permissions of the file you will run it from the command line like this "sh ./myconverter"

Additional Notes for Newbies

Samba is how you can share files over network between linux and windows. very handy. i have set up a pc under my desk that has two large harddrives (hdd) raided together. i have shared them so that i can access them from anywhere and get files or upload files to save them.

cups is the printer manager

deamons are good. pronounced like demons. they are processes that purposefully run in background. things like sshd, cupsd, smbd are the daemons that run ssh, cups and samba.


Posted by Connie on
Great stuff, you heepld me out so much!
Leave a Reply

(Your email will not be publicly displayed.)

Captcha Code

Click the image to see another captcha.