1 | find -size +10M -exec ls -lh {} \; |
1 | find -iname '*.jpg' -exec tar -rf bilder.tar {} \; |
1 | find -iname '*.mp3' -fprint playlist.m3u |
Find files with SUID bit set.
1 | find / -type f -perm +6000 -exec ls -l {} \; > suid.list |
1 | find -size +10M -exec ls -lh {} \; |
1 | find -iname '*.jpg' -exec tar -rf bilder.tar {} \; |
1 | find -iname '*.mp3' -fprint playlist.m3u |
Find files with SUID bit set.
1 | find / -type f -perm +6000 -exec ls -l {} \; > suid.list |
This is an example from http://www.linux-user.de/ausgabe/2001/07/030-split/split.html:
1 | tar cz /home/user | split -b95m - archiv.tgz.split. |
Put together files with:
1 | cat [dateiname].split.* | tar x |
To replace a string in all files inside a folder you can create a bash file:
1 | vi replace.sh |
Put inside this file:
1 2 3 4 5 6 | #!/bin/bash for file in $(ls -1); do sed 's/me/you/g' $file > /tmp/dummy.txt; mv /tmp/dummy.txt $file; done |
Save it and make it executeable (chmod 777 replace.sh)
1 2 3 4 5 | for file in $(ls -1); do mv $file $file.old sed 's/<b>/<strong>/g' $file.old > $file; done |
Another option is to use sed with -i command or direct editing:
1 2 3 4 | for file in $(ls -1); do sed -i 's/text_to_replace/text_replacement/g' $file done |
People often underestimate the usefulness of the linux-command screen.
What does screen do? Screen creates a terminal session for the actual user.
Type:
1 | screen |
to create a terminal session.
Or type:
1 | screen -S <sessionname> |
where <sessionname> should be replaced with your own name.
Create a new window:
1 | Crtl+a c |
which means (Press Control and a together and after that press c)
Now we created a second window. To list all created windows in the actual session type:
1 | Crtl+a " |
Germans have to press Shift+2 for “.
Now the two created windows will be shown:

Just choose one Window and press enter.
To quit your actual work an detach the session:
1 | Crtl+a d |
To list all active sessions:
1 | screen -list |
You should see a similar picture like the following:

Here you can see the name of the session: 1597.stefan
To restore the session simply type:
1 | screen -r stefan |
Maybe you have to type the complete id with 1597.stefan if there exist another session with the same name.
When switching from Mac to Linux and vice versa, I always have to think a bit about how to use the command top and sort by CPU.
With Linux it is
top
and then press
shift+p
Mac:
top -o cpu
I hope I can remember this
The situation is as follows. You want to search recursive for a text pattern inside of each files in the directory /var/www/vhosts. Take e.g. the pattern ‘DataStructure’.
Normally you would think about the find-command and executing another command but grep itself can do the job.
grep -RHl -e ‘DataStructure’ /srv/www/vhosts
This command lists all filenames containing the text ‘DataStructure’
To list all open connections on the actual linux or mac just type the following:
lsof -i
For faster lookup without replacing IP through DNS-lookup:
lsof -i -n
Try also with root-permission for more files:
sudo lsof -i -n
Now you can easily spot programs connecting to the internet an dump the tcp-data with tcpdump.
For example dumping data from tcp-port 80 to a file called test.pcap:
tcpdump -w test.pcap tcp port 80
Now show the file:
tcpdump -nnr test.pcap
or
tcpdump -ttttnnr test.pcap
for timestamp information
Normally it is not ab problem to convert a CMYK picture to a RGB picture with Photoshop. But what do you do if you have e.g. thousands of high quality pictures, and you want to convert these so RGB? With Linux you can easily convert your files.
All you need is
Installing ImageMagick and downloading the color profiles can not be explained here.
Now to convert picture called cmyk.jpg to rgb simply enter the following command:
convert -profile /pfad/zum/profil/USWebCoatedSWOP.icc \ -profile /pfad/zum/profil/ColorMatchRGB.icc cmyk.jpg rgb.jpg
For not writing the the whole line for each file create a bash-script:
#!/bin/bash
cmyk_profile=”/pfad/zum/profil/USWebCoatedSWOP.icc”
rgb_profile=”/pfad/zum/profil/ColorMatchRGB.icc”
ifile=”$1″ ofile=`basename “$ifile” .jpg`”_rgb.jpg”
convert -profile “$cmyk_profile” -profile “$rgb_profile” “$ifile” “$ofile”
Save this script as cmyk2rgb.sh and make it executeable with
chmod +x cmyk2rgb.sh
Now you can call this via:
./cmxk2rgb.sh bild.jpg
And a file called bild_rbb.jpg will be created.
Now other fine things are possible like find all files with ending .jpg and convert them to rgb:
for i in *jpg;
do
./cmyk2rgb.sh "$i";
done