Skip to content

Instantly share code, notes, and snippets.

@pepebe
Last active August 19, 2018 12:28
Show Gist options
  • Select an option

  • Save pepebe/864001cae6b49ea5cd3d82ad0df90de1 to your computer and use it in GitHub Desktop.

Select an option

Save pepebe/864001cae6b49ea5cd3d82ad0df90de1 to your computer and use it in GitHub Desktop.
Useful terminal commands (ongoing list)

set permissions

Source: https://stackoverflow.com/a/11512211

To change all the directories to 755 (drwxr-xr-x):

find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
find . -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r--r--):

find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
find . -type f -exec chmod 644 {} \;

Copy files:

Source: https://www.cyberciti.biz/faq/copy-folder-linux-command-line/

cp - copy from www to dev3 (recursive, include hidden files)

$ cp -avr /www/. /dev3

-a : Preserve the specified attributes such as directory an file mode, ownership, timestamps, if possible additional attributes: context, links, xattr, all. -v : Explain what is being done. -r : Copy directories recursively.

list directories

ls
ls -a all
ls -al all long
ls -alh all long human readable

in welcher Shell bin ich?

echo $0

Resultat bin/bash

find all files bigger than 500 MB

find /dir -size +500M -type f

find all empty directories

find . -type d -empty

find suspecious comments

find . -type f -exec "grep -EiH '/\*[0-9a-z]{5}\*/' '{}' " \;

Will return files containing things like this: /a245b/

find . -type f -exec bash -c "grep -EiH '/\*[0-9a-z]{5}\*/' '{}' " \;

Comments on one line

find . -type f -exec bash -c "grep -EiH '^/\*[0-9a-z]{5}\*/$' '{}' " \;

Rename results:

find . -type f -exec bash -c "grep -EiH '^/\*[0-9a-z]{5}\*/$' '{}' ; mv '{}' '{}'.suspicious" \;

zip folder

Source: http://www.webhostingtalk.com/showthread.php?t=544466

zip -r filename.zip foldername/

zip folder into multiple archives

Source: https://serverfault.com/questions/760337/how-to-zip-files-with-a-size-limit

Split a single directory including all subdirectories into multiple zip packages of 10 MB

$ zip -r -s 10m archive.zip directory/

You use an integer and a multiplier to define the maximum size of each package: The multiplier can currently be one of k (kilobytes), m (megabytes), g (gigabytes), or t (terabytes).

To unzip the file, the "zip" manpage explains that you should use the "-s 0`" switch:

 zip -s 0 split.zip --out unsplit.zip

will convert a split archive to a single-file archive.

So, you first "unsplit" the ZIP file using the "-s 0" switch:

$ zip -s 0 archive.zip --out unsplit.zip

... and then you unzip the unsplit file:

$ unzip unsplit.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment