Labsheet 0.1
Labsheet 0.1
The objective of this lab session is to gain familiarity with Linux environment which we will be using
for our programming activities.
Most commands are completed by pressing the enter key (also known as the return key)
1. Login into your Linux computer account using username and password.
2. While in graphical mode, open a terminal. This can be done by clicking the monitor like icon on the
task bar. Or you can right click on an empty portion of the screen and choose ‘Open Terminal’ option.
You are now ready to type commands. You can start multiple terminals in the graphical mode.
4. To change password, type "passwd". Follow instructions that appear. Choose a password that
contains letters and numbers. Note that the password will not be displayed.
5. Remember the new password. That will be the password next time you will use to log in to your
computer.
The terminal that we are using is a shell. We need some basic commands to
have our way around in the Linux environment. Try out all the commands and get familiar with these.
To learn more about a command and its options, use the man command (see below).
mkdir unixstuff
To see the directory you have just created, type
% ls
-1-
5. The parent directory (..)
Pathnames enable you to work out where you are in relation to the whole file-system. For
example, to find out the absolute pathname of your home-directory, type cd to get back to your
home-directory and then type
% pwd
/home/its/ug1/ee51vn
cp file1 file2 is the command which makes a copy of file1 in the current working directory and
calls it file2
8. mv: This command is used to move a file from one place to another. It is also used to rename a
file.. For example, if we wish to change the name of a file “file1” to “file2”, we can use
$ mv file1 file2
Use the rmdir command to remove a directory (make sure it is empty first).
% clear
11. man: Help for the meaning and usage of various commands. Help is provided for the
arguments given to it, e.g.
$ man ls
12. gedit: This command will start a text editor where you can create, edit and save a file. There
are a large number of editors like gvim etc. You may use any one of them to write your
programs. Open gedit, create a new file, save the file. Check various options available, such as
find/replace, etc.
-2-
13. tar: This command is used to bundle up (archive) many files into a single file.. For example,
place 3 files in a folder named dirname. Go up one level in folder hierarchy by using cd ..
Command. Now use the following command to tar the files –
$ tar -zcvf dirname.tar.gz dirname
15. ls -al: This command will show you files, directories, hidden files(starting with . such as
.bashrc or .bash_profile) along with file permission.
$ ls -al
16. cat: This command is used to view the contents of the file. All lines will be displayed on the
command line one after another
$ cat file1.txt
17. history: This command gives you the entire list of commands typed till the latest command.
$ history
--------- o O o ---------
-3-