To find the size of a directory
===============================
du -ch|grep total
du -chs /dir/*
To find the ip of the network
=============================
/sbin/ifconfig
To check the amount of memory
=============================
cat /proc/meminfo | grep MemTotal
To check the amount of swap memory
=============================
cat /proc/meminfo | grep SwapTotal
To check the kernal release of Linux
====================================
uname -a
To check the I/O at the OS level
================================
iostat
vmstat
To find whether Linux machine is 32 or 64 Bit
=============================================
getconf LONG_BIT
To find the OS version in Linux
===============================
cat /etc/redhat-release
cat /etc/issue
To find all users in Linux
==========================
cat /etc/passwd
To find no. of processors in server
===================================
cat /proc/cpuinfo | grep processor | wc -l
to show latest files in a directory
======================
find /dir1 -type f -mtime -1 -name "file*"
To search for a string among the files in a directory, below command for current directory
============================================================
grep -iR "search string" .
===============================
du -ch|grep total
du -chs /dir/*
To find the ip of the network
=============================
/sbin/ifconfig
To check the amount of memory
=============================
cat /proc/meminfo | grep MemTotal
To check the amount of swap memory
=============================
cat /proc/meminfo | grep SwapTotal
To check the kernal release of Linux
====================================
uname -a
To check the I/O at the OS level
================================
iostat
vmstat
To find whether Linux machine is 32 or 64 Bit
=============================================
getconf LONG_BIT
To find the OS version in Linux
===============================
cat /etc/redhat-release
cat /etc/issue
To find all users in Linux
==========================
cat /etc/passwd
To find no. of processors in server
===================================
cat /proc/cpuinfo | grep processor | wc -l
to show latest files in a directory
======================
find /dir1 -type f -mtime -1 -name "file*"
To search for a string among the files in a directory, below command for current directory
============================================================
grep -iR "search string" .
find recent files
=================
latest_file=`ssh IP_ADDR_OF_SERVER1 find /dir1 -type f -mtime -1 -name "file*"`
echo Staring SCP of $latest_file from SERVER1 to SERVER2...
/usr/bin/scp user@IP_ADDR_OF_SERVER1:$latest_file /dir2
echo SCP Completed.
ex
===
latest_file=`ssh -p 2022 modn-ldap2.lt.modeln.com find /archive/pngprd/rman -type f -mtime -1 -name "png*"`
echo Staring SCP of $latest_file from SERVER1 to SERVER2...
/usr/bin/scp -P 2022 rpilla@modn-ldap2.lt.modeln.com:$latest_file .
echo SCP Completed.
delete files older than x days
==============================
find rman*.gz -mtime +90 -exec rm {} \;
find a string in all files and list files
=========================================
grep -H "database" /home/rpilla/purge/*.lis
find files which are more then 100mb in the root directory
==========================================================
find / -xdev -type f -size +100000000c -exec ls -lh {} \;
find / -xdev -type f -size +2000000000c -exec ls -lh {} \;
To delete all files except one
==============================
rm !(filename.txt)
rm !(file1|file2)
if it does not work on bash then enable as below
shopt -s extglob
To show dates in history
=========================
HISTTIMEFORMAT="%d/%m/%y %T "
Random password generation
==========================
date |md5sum
scp fromdate to todate files
=============================
for i in `find . -type f -ctime -4`
do
scp -P 2022 $i rpilla@modndrdbp05.lt.modeln.com:~
done
split text file into equal lines
================================
split -l 4000 test.txt new
cat new* > newimage.jpg ------to join into a single file
Vi find and replace
=====================
The syntax is as follows:
:%s/WORD-To-Find-HERE/Replace-Word-Here/g
OR
:%s/FindMe/ReplaceME/g
No comments:
Post a Comment