If you have no idea what 'bash' is, Bash is the shell, or command language interpreter, for the gnu operating system. Descended from the Bourne Shell, Bash is a GNU product, the "Bourne Again SHell." It's the standard command line interface on most Linux machines. It excels at interactivity, supporting command line editing, completion, and recall. It also supports configurable prompts - most people realize this, but don't know how much can be done.
Also try reading CMI-Wiki http://www.cmi.ac.in/mediawiki1.9/index.php/ Using_computers
(Read more about bash at following links) http://en.wikipedia.org/wiki/Bash http://www.gnu.org/software/bash/manual/bashref.html This document is concerned about introducing 'extremely basic' commands to the uninitiated. For advanced reference go to ~hrishikeshrt/Shared/Linux/
------Introduction ------
This file lists and explains commands that you can run in one of the XShells Few most used XShells are "gnome-terminal", "konsole","xterm"
To run a terminal, Press Alt-F2 on your keyboard. "Run application" window will appear. Type in "gnome-terminal" there. Press 'Enter'
A new window will open. Most probably it will have something like following. hrishikeshrt@sl14:~ $ _ where in place of 'hrishikeshrt' you will have your username, in place of 'sl14' you will have name of machine you are logged in on, in place of '~' you will have your working directory. gnome-terminal (or any equivalent) will invoke a "bash" shell
So now having been acquainted with procedure of opening a terminal, we will see the commands that we type in the terminal to perform various actions.
------Symbols ------
Following symbols denote certain directories
/ root directory
~ Your home folder ~ = $HOME = /home/students/
.. The parent directoy of your current directory
------Important Files ------
~/.bash_profile ~/.bashrc ~/.bash_aliases (Most of you probably won't have this file) ~/.ssh/id_rsa ( ssh private-key)
* About alias alias is just way of setting names to certain commands.
alias SOMETHING='SOME OTHER THING' If you type this, then whatever used to happen by typing 'SOME OTHER THING' will now also happen when you type 'SOMETHING' eg. alias e='emacs'
In general you can add aliases to bashrc, but it is cleaner to put them in separate file.
Few useful aliases.
alias cls='reset' alias :r='. ~/.bashrc' alias adobe='pdfopen --file' alias la='ls -Al' alias ll='ls -l' alias ls='ls --color=auto' alias duf='du --exclude=mounts -ks * .[^.]* | sort -n;echo "";du -- exclude=mounts -sh' alias mkdir='mkdir -m 700' alias mplayer='mplayer -stop-xscreensaver -subfont-autoscale 1' alias mutt='mutt -z'
You can put them in your ~/.bash_aliases
------Reference ------Two useful commands - man & apropos If you know certain command and want to know what it does, type
$ man COMMAND where COMMAND is name of the command This will show a manual page about the usage of the command.
On the other hand if you want to search commands related to particular task, type
$ apropos KEYWORD
(Though soon most of you will realize that getting the right keyword might prove to be tedious and hence apropos is not much of use after all)
More resources are available at ~hrishikeshrt/Shared/Linux/
------Basic Commands ------
mkdir NAME Make a folder(directory) of name NAME
cd DIR Change directory to DIR
ls [DIR] List the files in the directory
cp SOURCE DESTINATION Copying files Copies from SOURCE to DESTINATION
mv FROM TO move files from FROM to TO
cat FILE Display contents of a text file
echo TEXT Prints on screen the TEXT given as input.
chmod OPTIONS FILE To change permissions of the FILE according to options. For Private files use chmod 700 FILE For Others chmod 755 FILE (To learn more about permissions and octal code, do man chmod)
whoami Displays your username.
du FILE shows size of file (man du for more)
exit (OR logout) Exit the shell
------Not so Basic ------
1) ssh-keygen -t rsa = create ssh rsa key. (create that in $HOME/.ssh)
2) Pipe | c1 | c2 = inputs output of c1 to c2
3) fusermount -u dir = to unmount the dir 4) sshfs path dir = mounts path on dir
5) grep expr input = gives all lines in input containing the expression
6) cat cat f1 = Returns f1 (Displays on screen) cat f1 f2 = concates f1 and f2 to standard output
7) > Redirects the output WITH overwrite (nothing on rhs => standard output)
>> Redirects the output WITHOUT overwrite e.g. cat f1 f2 > f3
8) du (-sh) (of file/dir) = disk space used (total) (of file/dir)
9) mkdir -m *** dir = create dir with given permissions ***
10) rar -v
------
Hrishikesh Terdalkar [email protected] Chennai Mathematical Institute