Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

UNIX IMPORTANT COMMANDS

Remote LogIn:

telnet <ip address> ENTER <username/password> ---- Not Encrypted.

ssh <ip address> ENTER <username/password> ---- Encrypted.

Logging Out:

logout ENTER

System ShutDown:

shutdown/shutdown –r/shutdown -h ENTER ----- Shuts down the system/Shutdown the system and restart/Shutdown
the system to turnoff physically.

halt ENTER -- Brings the system down immediately.

reboot ENTER -- Reboots the system.

init0 ENTER --- Powers off the system using predefined scripts to synchronize and
clean up the system prior to shutdown. (Not available on all Unix
systems.)

init6 ENTER - Reboots the system by shutting it down completely and then
bringing it completely back up. (Not available on all systems.)

poweroff ENTER --- Shuts down the system by powering off.

Switch User:

su <username>/su - <username> - switch user with the current environment and profile/switch user with the
user’s environment and profile.

Identifying the User:

whoami/who am I - Display the current logged in user/originally(initially) logged user on to the system.
User ID Information:

Id/groups ---Display the user id information and groups to which user belongs to/Display only groups
information.

Navigating the File System:

pwd - shows the current directory the user is in.

cd </directory name>/cd enter/cd ../ - moved to another directory/return to the home directory/return one
step back.

ls/ls –l /ls –a/ls |pg-list the contents of any directory/list the contents of any directory with additional
information(permission associated, owner, group to which owner belongs, size of the file, last modified
date)/include the hidden content/list the content page wise.

file<filename> -- to determine the file type.

rm <filename>/rm -rf-- removes file/remove the directories and subdirectories.

rmdir<directoryname>---removed directory.

cat<filename> --- displays a file.

head<filename>/head –n <filename>---shows a beginning of a file/shows the first n lines of a file

tail<filename>/tail –n <filename>---shows the end of a file/shows the last n lines of a file

more<filename>---display the contents of file

less<filename>--display the contents of file with back and forward capability

cp<filename path to copy>-copy a file/directory to a specified location

mv<sourcepath> <destinationpath> - moves a file or directory from one location to another with copy. Also
uses for rename a file or directory

touch <filename> --creates a blank file

mkdir <directoryname> -creates a directory

rmdir<directoryname> --removes a directory

Permissions and Ownership:

chmod <nnn> <file name> - change the permission of the given file according to the n arguments.

n=0 no permission

n=1 execute permission


n=2 write permission

n=3 execute and write permission

n=4 read permission

n=5 read and execute permission

n=6 read and write permission

n=7 all permission(read write execute)

chown <user> <filename>/chown <owner:group> <directory> -- change the ownership of the file to the
specified user.

File System Management:

bdf--display the disk space usage in kilobyte

du <directory path or directoryname> -display the disk space usage for a directory

mount/mount –t <filesystemtpye> <devicetomount> <directorytomountto> -display the current mount


system/mount the file system with the associated parameters

Vi editor:

Command mode:

Moving Around in a File

Key Movement
--- --------
w forward word by word
b backward word by word
$ to end of line
0 (zero) to beginning of line
H to top line of screen
M to middle line of screen
L to last line of screen
G to last line of file
1G to first line of file
<Control>f scroll forward one screen
<Control>b scroll backward one screen
<Control>d scroll down one-half screen
<Control>u scroll up one-half screen
Undoing
To undo your most recent edit, type
u
To undo all the edits on a single line, type
U (uppercase)
Undoing all edits on a single line only works as long as the cursor stays on that
line. Once you move the cursor off a line, you cannot use U to restore the line.

Opening a Blank Line

To insert a blank line below the current line, type

o (lowercase)

To insert a blank line above the current line, type


O (uppercase)

Deleting Lines

To delete a whole line, type


dd
The cursor does not have to be at the beginning of the line. Typing dd deletes the
entire line containing the cursor and places the cursor at the start of the next line.
To delete two lines, type
2dd
To delete from the cursor position to the end of the line, type
D (uppercase)

Deleting Words

To delete a word, move the cursor to the first letter of the word, and type
dw
This command deletes the word and the space following it.
To delete three words type
3dw

Deleting Characters
To delete a character from a file, move the cursor until it is on the incorrect letter,
then type
x
The character under the cursor disappears. To remove four characters (the one
under the cursor and the next three) type
4x
To delete the character before the cursor, type
X (uppercase)

Entering Text

In order to begin entering text in this empty file, you must change from command
mode to insert mode. To do this, type
i
Nothing appears to change, but you are now in insert mode and can begin typing
text. In general, vi's commands do not display on the screen and do not require
the Return key to be pressed.
Type a few short lines and press <Return> at the end of each line. If you type a
long line, you will notice the vi does not word wrap, it merely breaks the line
unceremoniously at the edge of the screen.
If you make a mistake, pressing <Backspace> or <Delete> may remove the
error, depending on your terminal type.
Moving the Cursor
To move the cursor to another position, you must be in command mode. If you
have just finished typing text, you are still in insert mode. Go back to command
mode by pressing <Esc>. If you are not sure which mode you are in, press
<Esc> once or twice until you hear a beep. When you hear the beep, you are in
command mode.
The cursor is controlled with four keys: h, j, k, l.
Key Cursor Movement
--- ---------------
h left one space
j down one line
k up one line
l right one space
Esci<space> spacebar

Exiting and saving a file

:q! quits without saving.

:wq quits with saving


Insert text

i Inserts text before current cursor location


I Inserts text at beginning of current line
a Inserts text after current cursor location
A Inserts text at end of current line

Transferring Files between Systems:

ftp <Ip address> Enter

get <filename> ---retrieve a file from a remote FTP.

send <filename>----sends a file to a remote FTP.

Process Management:

ps –aef|grep sap-----list the process id related to sap.

Kill <pid>-----kill the specified process.

You might also like