Daily usage Linux Commands for Any Middleware Administration

Daily usage Linux Commands for Any Middleware Administration


Processes related:
------------------


$ ps -ef | grep <process_name> ----- will show the process ID of the proces


$ ps -eaf --> to see the Process ID's


$ telnet <hostname> <Port_Number> --> It is used to check whether port(server) is listening or not


$ scp    -r     file_Name     username@hostname:path  ----- If you want to copy a file from one linux server to another sever


$ kill -9 PID ----- Killing an unwanted process


$ kill -3 PID ----- Used to take thredDump of the process


$ ssh username@servername --> Command used to login to server


$ nslookup <host_name> --> Query the nameserver for the IP address of the given HOST optionally using a specified DNS server (To identify the server ip_address by using nslookup command )


$ crontab Minute Hour DayOfMonth Month DayOfWeek (eg: 30 08 10 06 * /home/was/full-backup) ----- Used to scheduled a job on Linux System 
       $ corntab -e ----- To create a cornjob
       $ corntab -l ----- To disply the created jobs


$ sudo useradd user_name ----- add a user
        $ sudo passwd user_name ----- change password for the user
        $ sudo userdel user_name ----- remove the user
        $ sudo su - root ----- Change to root admin


$ ping ----- Used to check if you are connected to the internet or if a remote host is running


$ wget ----- Used to download the files from internet



Compress and Extract:
---------------------


$ tar ----- To Compress and extract the files or folders
       $ tar   -cvf   file.tar    file_Name  ----- To compress the files/Directories
       $ tar   -xvf   file.tar  -----  To extract the files/Directories


$ gzip <file/Directory_Name> ----- To Compress
$ gunzip <file/Directory.gz> ----- To uncompress



Network Related:
----------------



$ ifconfig ----- To viewing and configuring network information on linux machine
       $ ifconfig unplumb hme0 ----- will disable ethernet interface
       $ ifconfig plumb hme0  ----- will enable 


Listing Files:
--------------


$ ls      --> List files on specified directory
$ ls -a   --> List all files on specified directory include hidden files
$ ls -ltr --> List the all files

ls {path}        --> It's ok to combine attributes, eg ls -laF gets a long listing of all files with types.

ls {path_1}      --> {path_2} List both {path_1} and {path_2}.

ls -l {path}     --> Long listing, with date, size and permisions.

ls -a {path}     --> Show all files, including important .dot files that don't otherwise show.

ls -F {path}     --> Show type of each file. "/" = directory, "*" = executable.

ls -R {path}     --> Recursive listing, with all subdirs.

ls {path} | more --> Show listing one screen at a time.


$ lsof -i : Port_Number --> It will give listening status of port.


To find out largest files --> ls -lsh . | head -5


=====================================================================


Info Related Commands:
----------------------


$ pwd --> It prints present working directory


$ who or w ----- Will disply more info about the users logged into Terminal or Server


$ uptime ----- will show how long the system has been up and also shows CPU Load, Number of users logged in etc.,


$ hostid ----- shows unique identifier of host


$ uname -a ----- will show sytem name, solaris, platform and some more information


$ hostname ----- will give your system name


$ cat /proc/cpuinfo  --> To see your CPU Information


$ cat /proc/meminfo  --> To see memory Information


$ vmstat  -->   It is a performance monitoring command of the system as it gives the information about processes, memory, paging, block IO, disk, and CPU scheduling (virtual memory statistic reporter)


$ top ----- This Command displays the real time summary/information of our system. Show all process and memory, cpu etc., utlisation


$ free ----- To get the infromation about system memory or RAM.


$ man ----- Manual page of a command


$ netstat ----- Show network statistics


=====================================================================


Directory/File managing Commands:
---------------------------------


$ cd .. --> Used to navigate (takes to you previous directroy)
$ cd -  --> Used to go to previous path


$ mkdir -- Used to create Directory
$ mkdir -p Dir1/dir4/dir5 -- Creates Subdirectories(will create all the non-existing Directories)


$ cp -r --> Copy the files/directories recursively


$ mv -r --> Move the files/directories recursively


$ mv <File_Name/Directory_Name> --> To change file/directory name


$ find ----- To search for a specific file or Directroy
        
eg: $ find    /Dir_Name    -WAS   ----- It will shows WAS files in specified directory
    $ find    /Dir_Name    -WAS  *.jpeg   ----- It will shows all .jpeg files in specified directory


If you need to find the files that have a modification date older than N, for example older than 30 days? In that case you need to use +N instead of -N,     like this:


find /directory/path/ -mtime +N -ls


$ rm ----- Delete the file specified
$ rm * ----- Delete all the files/directories in the present directory


Disk Usage and file system usage checkup commands:
--------------------------------------------------



$ du -sk <dir/File_Name> ----- Display the size of the files/folder (Disk Usage)



$ du -ksh * --> Will display the file of the individual files in particular file system



To see the largest 10files in the linux box:
--------------------------------------------


$ du -a <path> | sort -n -r | head -n 10


$ du -hsx * | Sort -rh | head - 10


$ df -k or h ----- will show all the mounted file systems.


=====================================================================


To Files View Purpose Commands:
-------------------------------



$ touch ----- creates a dummy file


$ more ----- Displays page by page contents of file


$ less ------ Once you’ve opened a log file (or any file) using less file-name


$ grep ----- Checks pattern/word in a file_Name specified


$ cat ------ Display the content of file

eg:$ cat > textfile.txt
This is a file created by using cat command.
To Exit --> "ctrl + d"


$ cat >> textfile.txt --> add the text by using this type


$ head ----- Show first 10Lines of the file


$ tail ----- Show end 10Lines of the file
$ tail -f ----- for continuos update of file
$ tail -N SystemOut.log |grep -i server or error or etc., --> To use "Ctrl + G" go to end of the file


$ locate file_Name/Directory_Name ----- To locate files and folders 


$ file <file_Name> ----- Prints type of file 


$ history ----- Prints history of commands entered on the Terminal
       eg: $ history | grep cat ----- It prints cat command history


$ clear ----- To clear the terminal screen(ctrl + L)


=====================================================================



vi Editor:
----------


To save and quit:
-----------------


:wq!     --> Save and quit
:w       --> Save
:q       --> Quit
:w fname --> Save as fname
ZZ       --> Save and quit
:q!      --> Quit discarding changes made
:w!      --> Save (and write to non-writable file)


To move around a file:
----------------------


j  --> To move down
k  --> To move up
h  --> To move left
l  --> To move right
w  --> Move one word forward
b  --> Move one word backward
<n>w  --> Move specified number of words forward
dw    --> Delete one word
yw    --> Copy one word
<n>dw --> Delete specified number of words


Replace all:
------------


Syntax: $:<startLine,endLine> s/<oldString>/<newString>/g 

Example:
--------
$:1,$ s/readable/changed/ --> Replace forward with backward from first line to the last line
$:3,6 s/letters/neww/g   --> Replace forward with backward from third line to the ninth line



To switch from command to insert mode:
--------------------------------------


i  --> Start typing before the current character
I  --> Start typing at the start of current line
a  --> Start typing after the current character
A  --> Start typing at the end of current line
o  --> Start typing on a new line after the current line
O  --> Start typing on a new line before the current line


To jump lines:
--------------


G  --> Will direct you at the last line of the file

" --> Will direct you to your last position in the file

To delete:
----------


x  --> Delete the current character
X  --> Delete the character before the cursor
r  --> Replace the current character
xp --> Switch two characters
dd --> Delete the current line
D  --> Delete the current line from current character to the end of the line
dG --> delete from the current line to the end of the file

To repeat and undo:
-------------------


u  --> Undo the last command
.  --> Repeat the last command


Command to cut, copy and paste:
-------------------------------


dd  --> Delete a line
yy  --> (yank yank) copy a line
p   --> Paste after the current line
P   --> Paste before the current line
-------
<n>dd  -->  Delete the specified n number of lines
<n>yy  -->  Copy the specified n number of lines

Joining lines:
--------------


J   --> Join two lines
yyp --> Repeat the current line
ddp --> Swap two lines


Search a string:
----------------


/string    --> Forward search for given string
?string    --> Backward search for given string
/^string   --> Forward search string at beginning of a line
/string$   --> Forward search string at end of a line
n    -->  Go to next occurrence of searched string
/\<he\>    --> Search for the word he (and not for there, here, etc.)
/pl[abc]ce --> Search for place, plbce, and plcce






Comments

Post a Comment

Popular posts from this blog

IBM WebSphere - Synchronize a node (syncNode)

Backup and Restore of WebSphere Application Server configuration