Linux Tricks and Techniques

For Linux Experts

Use the website for easy leaning of Linux

Thursday, 21 July 2016

Linux Useful Commands

Linux Useful Commands

Sometimes we face small issues in the Linux for which there is small commands need to be run and the issue get resolved. For these kind of issues we may need to merge some commands to get the desired output. This also based on the basic knowledge of a Linux admin how he look at the issue and what strikes in his/her mind to resolve it.

Some of the useful commands for such issues are as follows:

1. In Linux/Unix sometimes we need to delete some unwanted files which is quite easy to do but if there are tons of files need to be deleted then a admin want to delete them in one command. To delete these files in one command use

# for i in`cat`; do rm $i; done  press enter and then submit files

Also we can use a small script like

#  for i in `cat input.txt`;
     rm -f $i

 To Find all files having .bak (*.bak) extension in the current directory and remove them

# find . -type f -name "*.bak" -exec rm -f {} \;

2. Sometimes when we need to mount any directory and is shows busy or already mounted then use the command

 #fuser -cu /dir ------ to check which user has hold the dir.
#fuser -ck /dir ------- to kill the user and get the dir free.
#mount -o remount /dir ----- then remount the dir.

3. If the mount point is reached to the 100 % then need to check the background processes

# lsof  +L1 | grep deleted

to check files open by a user

#losf -u username

if these files are already deleted that means that these files are still consuming the space and causing the mount point full. So to kill these processes to release the space

# kill -9 pid

4. To check the permissions to a user

# id -a usename

5. To check the Oracle instances on a Linux server

# ps -ef | grep pmon


No comments:
Write comments