Essential Commands in Linux Environment
Essential Commands in Linux Environment
To connect to Red Hat Linux Server go to Start-Run and in the Open box type:
telnet 172.16.22.5 After connected to Linux Server a window will open waiting for your login id and
password. Enter your college id as below.
For e.g. if your college id is 2010A3PS200U login : u2015a3ps200 [all in small case ‘u’ in front]
In linux vi is one of the most popular editor to create or edit any source files.
i.) At the $ prompt type vi filename.c this will open a editor.
ii) To start typing the code give the command Esc i [press escape key once and the letter i]
the word insert will appear at the left bottom of your screen now u can start typing your code.
iii) Once finish typing to save the file give the command Esc:wq (i.e. press the escape key once
the word insert at your left bottom will disappear, then hold the shift key and give colone [:]
then give the command wq – [meaning write and quit]). Now you have written your c
program and saved it, to check whether it saved, type the command ls and see.
Joe is another user friendly editor in linux which helps the user to create and edit source file as vi editor.
At the $ prompt type joe filename.c an editor window will open then press cntrl k h [i.e. hold the
Control key then press the keys k h. An help window will open, there you will find all the list of commands.
Start typing your program the give the command cntrl k x for save and exit. Compile and Run procedures
remain same as step no. 7.
mv file1.c file2.c - This command will move the contents of file1.c to file2.c
in other words it will rename the filename.
man - manual used to get help on linux
commands. Example: To get help for “ls” type man ls
cp - copy contents from one file to another. Syntax: cp file1.c file2.c
cat - to display the contents of one file for e.g. cat text.c will display the
contents of file text.c
rm - Remove file (or delete file). Syntax:rm text.c removes the file
text.c, similarly rm *.c will delete all the files with .c extension.
Esc:q! - In the vi editor after typing your source code instead of saving a file
[quit without saving if you want to quit without saving the give :q! – this will exit the
editor without saving.
Esc: wq filename- Incase you open a file called abc.c and the same contents you want
to Save in another file called xyz.c . Open the file abc.c and while
exit give Esc: wq xyz.c this is something like save as in MsWord.
2
REGULAR STEPS:-
Program...............................
................................................ The source code you typed in your
system.
………………………. [Continuity of the code write on
right side
of next page don't continue
behind]
Sample Input:
Write Left Hand side of your
Journal
Sample Output: `
3