Linux Basics
Linux Basics
Kernel
Shell
User Application
[root@localhost ~]#
• Open To open a file in the vi editor from the command line interface, run the vi filename
command.
• Search Start with a backslash, followed by the search term. Remember, Linux is casesensitive,
so if you're searching for "Michael" in /etc/passwd, use the /Michael (not /michael) command.
• Write To save your changes, use the w command. You can combine commands: for example,
:wq writes the file and exits vi.
• Close To leave vi, use the :q command.
• Abandon If you want to abandon any changes that you've made, use the :q! command.
• Edit You can use a number of commands to edit files through vi, such as x, which deletes the
currently highlighted character; dw, which deletes the currently highlighted word; and dd, which
deletes the current line. Remember, p places text from a buffer, and U restores text from a
previous change.
• Insert A number of commands allow you to start insert mode, including i to start inserting text at
the current position of the editor, and o to open up a new line immediately below the current
position of the cursor.
Basic Commands
• cat -- To display text file. – Syntax -- cat {file name} Examples - $cat foo
• cd - To change current directory. – Syntax - cd {directory name} Options - (minus) Change to previous directory
location.
Examples
$ cd /usr/local/apache
$ pwd
/usr/local/apache
$ cd /var/log
$ pwd
/var/log
$ cd –
$ pwd
/usr/local/apache
$ cd (Change to home directory)
NOTE: Linux’s $OLDPWD variable holds your last directory setting, if you type $ cd $OLDPWD, it is same as $ cd -.
What happen if you type $ cd – as soon as you login into Linux?
• Note that each shell does the same job, but each understand a different command
syntax and provides different built-in functions.
• In MS-DOS, Shell name is COMMAND.COM which is also used for same purpose,
but it's not as powerful as our Linux Shells are!
• Any of the above shell reads command from user (via Keyboard or Mouse) and tells
Linux Os what users want. If we are giving commands from keyboard it is called
command line interface (Usually in-front of $ prompt. This prompt is depend upon
your shell and Environment that you set or by your System Administrator, therefore
you may get different prompt).