Use awk to strip a file of empty line. Do it with
awk ‘NF>0′ < text_file
Use awk to strip a file of empty line. Do it with
awk ‘NF>0′ < text_file
If you run Linux off a laptop, you might want to check your battery status alt least once a year:
grep -F capacity: /proc/acpi/battery/BAT0/info This will output something like
design capacity: 7800 mAh
last full capacity: 6414 mAh
Afraid you might mess up your MBR? Back up the bootsector:
dd if=/dev/hda of=bootsector.img bs=512 count=1 If anything goes wrong, you can boot from a LiveCD and restore the bootsector with
dd if=bootsector.img of=/dev/hda
Want to convert a subtitle file to a different encoding? Use
iconv -f WINDOWS-1253 -t ISO-8859-7 subtitle_file.srt
You can do this by installing cpulimit. You can limit a certain running application either by name or by process ID:
cpulimit -e firefox -l 30 This won’t let Firefox go beyond a 30% CPU usage limit.
If you’d rather go by process, you can do it like this:
cpulimit -p 3493 -l 40 This will limit process number 3493 to 40% CPU consumption.
smbmount “\\\\WINDOWS\\c” -c ‘mount /mount/Windows’ -I 192.168.0.3 To find out what external IP address your router has assigned to it, you can either search the Internet for sites that can display that said IP address or you can use the Linux command line:
wget -O - -q icanhazip.com for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo “192.168.1.$ip UP” || : ; done watch -d -n 2 ‘df; ls -FlAt;’ Display the current directory as a webpage in Linux
python -m SimpleHTTPServerin the directory you wish to share, then access http://127.0.0.1:8000 in your browser.
Encrypt file:
gpg -c private.txtYou will be prompted to enter a passphrase twice. The output is a file of the same name with ".gpg" as the extension.
Decrypt via:
gpg private.txt.gpgBy default the encrypted file is binary format with smaller file size. If you need ascii, then use the "-a" option which then outputs as "private.txt.asc".