10 Quick Linux tips and tricks for DevOps??: How to Make the Search Insensitive and Others.

10 Quick Linux tips and tricks for DevOps??: How to Make the Search Insensitive and Others.

Here is some quick tips for better work with Linux, used in my DevOps practice.


1. As you know, Linux and the UNIX system are case-sensitive. What if you need to find any specific text, but you not sure if it’s lowercase or uppercase?

Simply use the grep -i command; it makes the search insensitive to case.


2. Instead of doing this:

mkdir mydir
cd mydir        

Add this function to the ~/.bashrc and call it next time:

function mkcd {
 if [ ! -n "$1" ]; then
 echo "Enter mkcd followed by a directory name"
 elif [ -d $1 ]; then
 echo "\`$1' already exists"
 else
 mkdir $1 && cd $1
 fi
}        

3. Find all files that were edited in the last 10 minutes:

find . -type f -mmin -10        

4. Check the disk usage to find out which files are taking the most disk space:

sudo du -hsx /* | sort -rh | head -n 5        

5. Run multiple commands with one command:

command1 ; command2 ; command3 ; command4        

6. Run the following command only if the previous one runs successfully:

command1 && command2 && command3 && command4        

7. List files sorted by size:

ls -l        

8. Get the virtual memory statistics report:

vmstat 1 5
# 1 = the values will be re-measured and reported every second.
# 5 = the values will be reported five times, and then the program will stop.        

9. Display file permissions in a user-friendly format.

getfacl        

10. Add a timestamp to your bash history, execute:

export HISTTIMEFORMAT="%d/%m/%y %T "        

Add this line to the?.bashrc if you want to make it permanent.



要查看或添加评论,请登录

Andrey Byhalenko的更多文章

社区洞察

其他会员也浏览了