Last active
December 31, 2015 21:28
-
-
Save DarkPark/8046568 to your computer and use it in GitHub Desktop.
set of useful commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# turn off the given monitor | |
xrandr --output LVDS --off | |
# enable/disable composting | |
xfconf-query --channel=xfwm4 --property=/general/use_compositing --type=bool --toggle | |
# exit the script if try to use an uninitialized variable | |
set -u | |
# exit the script if any statement returns a non-true return value | |
set -e | |
# SSH socks proxy | |
ssh -D 5555 user@remotehost -f -N | |
# map the remote port 3306 to local 33060 | |
ssh -L 33060:127.0.0.1:3306 user@remotehost | |
# file creation of the given size | |
dd if=/dev/zero of=file.dat count=1 bs=1M | |
truncate -s 10G file.dat | |
fallocate -l 5T file.dat | |
# iterating files | |
for f in file1 file2 file3; do echo "processing $f"; done | |
for f in *.txt; do echo "processing $f"; done | |
# processing file line by line with separation | |
while read part1 part2 part3; do | |
echo "$part3 :: $part1" | |
done < data.txt | |
# find & replace across multiple files | |
find . -type f -name "*.txt" -print0 | xargs --null sed -i "s/foo/bar/g" | |
find . -type f -name "*.txt" -exec sed -i 's/foo/bar/g' "{}" \; # many sed processes | |
find . -type f -name "*.txt" -exec sed -i 's/foo/bar/g' "{}" +; # single sed process | |
# files and dirs recursive permissions correction | |
find /some/path/ -type f -exec chmod 644 "{}" \; | |
find /some/path/ -type d -exec chmod 755 "{}" \; | |
# change files ownership in a directory recursively from a user to another | |
chown -cR --from=olduser:oldgroup newuser:newgroup ./* | |
find . -user olduser -exec chown newuser:newgroup "{}" \; | |
find . -uid 1024 -exec chown newuser:newgroup "{}" \; | |
# remove files recursively | |
find -name "smth.*" | xargs rm; | |
find -name "smth.*" -exec rm {} \; | |
find -name "smth.*" -delete; | |
rm -rvf smth.* | |
rm -- smth* | |
# remove all duplicates in the current directory | |
fdupes --recurse --delete --noprompt . | |
# delete all empty folders in current directory | |
find . -type d -empty -delete | |
# file lines count | |
wc -l some.txt | |
sed -ne '$=' some.txt | |
grep -c "" some.txt | |
# get media file meta-data | |
mplayer -vo null -ao null -identify -frames 0 -v somefile.mkv | |
# play video with two audio tracks simultaneous output to different sound cards | |
mplayer -udp-slave -aid 0 -vo null -ao alsa:device=hw=1.0 somefile.mkv | |
mplayer -udp-master -aid 1 somefile.mkv | |
# extract audio track from video file | |
avconv -i media.avi -acodec copy -y media.mp3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment