วันจันทร์ที่ 6 พฤศจิกายน พ.ศ. 2566

วันอาทิตย์ที่ 6 สิงหาคม พ.ศ. 2566

reset esxi root password

 https://www.youtube.com/watch?v=0L-lFCbOVgk


sudo su -

mkdir /temp

mount /dev/sda5 /boot

cd /boot

cp state.tgz /temp

cd /temp

tar -xf state.tgz 

tar -xf local.tgz 

rm *.tgz

cd etc

nano shadow

cat shadow

root::18355


cd ..


you are in /temp

 

tar -cf local.tgz etc/

tar -cf state.tgz local.tgz

mv state.tgz /boot

umount /boot

reboot


set a new password

วันพฤหัสบดีที่ 27 กุมภาพันธ์ พ.ศ. 2563

วันจันทร์ที่ 9 กันยายน พ.ศ. 2562

To find biggest file in top 5 in directory linux

How to Find Biggest Files and Directories in Linux

Run the following command to find out top biggest directories under /home partition.
# du -a /home | sort -n -r | head -n 5
Find Largest Directories in Linux
Find Largest Directories in Linux
The above command displays the biggest 5 directories of my /home partition.

Find Largest Directories in Linux

If you want to display the biggest directories in the current working directory, run:
# du -a | sort -n -r | head -n 5
Find Biggest Directories Only
Find Biggest Directories Only
Let us break down the command and see what says each parameter.
  1. du command: Estimate file space usage.
  2. a : Displays all files and folders.
  3. sort command : Sort lines of text files.
  4. -n : Compare according to string numerical value.
  5. -r : Reverse the result of comparisons.
  6. head : Output the first part of files.
  7. -n : Print the first ‘n’ lines. (In our case, We displayed first 5 lines).
Some of you would like to display the above result in human readable format. i.e you might want to display the largest files in KBMB, or GB.
# du -hs * | sort -rh | head -5
Find Top Directories Sizes in Linux
Find Top Directories Sizes in Linux
The above command will show the top directories, which are eating up more disk space. If you feel that some directories are not important, you can simply delete few sub-directories or delete the entire folder to free up some space.
To display the largest folders/files including the sub-directories, run:
# du -Sh | sort -rh | head -5
Find Largest Folder and Sub directories
Find Largest Folder and Sub directories
Find out the meaning of each options using in above command:
  1. du command: Estimate file space usage.
  2. -h : Print sizes in human readable format (e.g., 10MB).
  3. -S : Do not include size of subdirectories.
  4. -s : Display only a total for each argument.
  5. sort command : sort lines of text files.
  6. -r : Reverse the result of comparisons.
  7. -h : Compare human readable numbers (e.g., 2K, 1G).
  8. head : Output the first part of files.

Find Out Top File Sizes Only

If you want to display the biggest file sizes only, then run the following command:

find -type f | xargs  -I {} du -h {}

# find -type f -exec du -Sh {} + | sort -rh | head -n 5
Find Top File Sizes in Linux
Find Top File Sizes in Linux
To find the largest files in a particular location, just include the path besides the find command:
# find /home/tecmint/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5
OR
# find /home/tecmint/Downloads/ -type f -printf "%s %p\n" | sort -rn | head -n 5
Find Top File Size in Specific Location

วันอาทิตย์ที่ 10 กุมภาพันธ์ พ.ศ. 2562

idrac CLI

# power server off racadm serveraction powerdown # power server on racadm serveraction powerup # perform server power cycle racadm serveraction powercycle # force hard server power reset racadm serveraction hardreset # display current power status of server racadm serveraction powerstatus

expect ssh to output file

#!/usr/bin/expect -f
set user "root"
set password "toor"
set ip "10.0.0.88"

spawn ssh $user@$ip
expect "password:"
sleep 1
send "$password\r"

expect ">" {send "racadm getsysinfo\r"} >/home/ssh.txt
expect ">" {send "exit\r"}
set output [open "outputfile.txt" "a+"]
set outcome $expect_out(buffer)
puts $output $outcome
close $output
expect EOF