nl
stringlengths
13
387
bash
stringlengths
1
532
Set permissions to 400 for regular files under the current directory
find . -type f -exec chmod 400 {} \;
Set permissions to 600 for regular files under var/
find var/ -type f -exec chmod 600 {} \;
Set permissions to 644 for all regular files under the current directory tree that have permissions 755
find . -type f -perm 755 -exec chmod 644 {} \;
Set permissions to 660 for all regular files in the current directory tree
find . -type f -exec chmod 0660 {} +
Set permissions to 700 for directories under media/
find media/ -type d -exec chmod 700 {} \;
Set permissions to 700 for directories under var/
find var/ -type d -exec chmod 700 {} \;
Set permissions to 700 for every subdirectory of the current directory
find . -mindepth 1 -type d -print0 | xargs -0 chmod -R 700
Set permissions to 755 for every subdirectory of the current directory
find . -type d -mindepth 1 -print -exec chmod 755 {}/* \;
Set permissions to ug=rw,o= for files under the $d directory tree
find $d -type f -exec chmod ug=rw,o= '{}' \;
Set permissions to ug=rwx,o= for directories inside the ./default/files tree
find ./default/files -type d -exec chmod ug=rwx,o= '{}' \;
Set permissions to ug=rwx,o= for directories under the $d directory tree
find $d -type d -exec chmod ug=rwx,o= '{}' \;
Set prompt to the system host name and history number
PS1="`hostname`:\!>"
Set the read bit for "other" on all *rc.conf files in the current directory tree
find . -name "*rc.conf" -exec chmod o+r '{}' \;
Set read, write and execute permission for all (owner, group, other) for the files/directories in foldername directory tree
sudo find foldername -exec chmod a+rwx {} ";"
Set the setgid bit on all directories in the repository "/git/our_repos"
find /git/our_repos -type d -exec chmod g+s {} +
Set shell option 'checkwinsize'.
shopt -s checkwinsize
Set shell option 'dotglob'.
shopt -s dotglob
Sets shell option 'dotglob'.
shopt -s dotglob
Sets shell option 'extglob'.
shopt -s extglob
Sets shell options 'extglob' and 'nullglob'.
shopt -s nullglob extglob
Sets shell option 'globstar'.
shopt -s globstar
Sets shell options 'globstar', 'dotglob' and 'nullglob'.
shopt -s globstar nullglob dotglob
Sets shell options 'globstar' and 'nullglob'.
shopt -s globstar nullglob
Set shell option 'histverify'.
shopt -s histverify
Sets shell option 'nounset'.
shopt -s -o nounset
Sets shell option 'nullglob'.
shopt -s nullglob
Set the system date to Sat May 11 06:00:00 IDT 2013
sudo date --set="Sat May 11 06:00:00 IDT 2013"
Set timestamp of all PHP files in current directory to date specified.
touch -d '30 August 2013' *.php
Set the timestamp of B to the same one as A
touch -r A B
Set timestamp of B to the timestamp in stat format specified by variable "old_time"
touch -d"$(date --date="@$old_time")" B
Set trace prompt to print seconds.nanoseconds
PS4='+ $(date "+%s.%N")\011 '
Set up a local SSH tunnel from port 80 to port 3000
ssh $USERNAME@localhost -L 80:localhost:3000 -N
Set up a local SSH tunnel from port 80 to port 3000
sudo ssh $USERNAME@localhost -L 80:localhost:3000 -N
Set up a remote port forward from port 10022 on host "server" to port 22 on localhost
ssh -R 10022:localhost:22 device@server
Set up local port forwards in the background with no terminal or command execution from port 4431 to host "www1" port 443 and port 4432 to host "www2" port 443 via the host "colocatedserver"
ssh -fNT -L4431:www1:443 -L4432:www2:443 colocatedserver
Set up SSH connection forwarding in the background with no terminal or command execution from localhost port 8888 to "proxyhost" port 8888 and a reverse connection from "officefirewall" port 22222 to "localhost" port 22
ssh -fNT -L8888:proxyhost:8888 -R22222:localhost:22 officefirewall
Set the value of "to_sort" to "$1" in a subshell which no longer exists after the pipeline completes
echo "$1"| read -a to_sort
Set variable "architecture" to machine architecture, ie. x86_64
architecture="$(uname -m)"
Set variable "extract_dir" to list of top-level directories and files contained in tar archive specified by variable FILE.
extract_dir=$(tar -tf $FILE | cut -d/ -f1 | uniq)
Set variable "filename" to only the name of document specified by URL, in this case "pic.jpg"
filename="`basename "http://pics.sitename.com/images/191211/pic.jpg"`"
Set variable "finalName" to the second-to-last slash-separated path component of variable "path"
finalName=$(basename -- "$(dirname -- "$path")")
Set variable "fname" to the basename of path specified in variable "f", that is remove everything up to the last slash if present.
fname=`basename $f`
Set the variable "me" to the name of the running script.
me=`basename "$0"`
Set the variable "me" to the name of the running script, or shell, login shells have a hyphen appended to the beginning of the name, such as "-bash".
me=`basename -- "$0"`
set variable "uname_m" to machine architecture, ie. x86_64
uname_m=`uname -m`
Set variable 'file' to the base name of first argument to script or function, that is the part following the last slash.
file=$( basename "$1" )
Set variable 'file' to the base name of first argument to script or function, that is the part following the last slash.
file=`basename "$1"`
Set variable 'path' to name of current directory (without the containing directories).
path=$(basename $(pwd))
Set variable 'path' to name of current directory (without the containing directories) converted to lowercase.
path=$(basename $(pwd) | tr 'A-Z' 'a-z' )
Set variable 'rav' to the contents of 'var' spelled backwards.
rav=$(echo $var | rev)
Set variable BZIP2_CMD to the full path of command "bzip2"
BZIP2_CMD=`which bzip2`
Set variable GZIP to the full path of command "gzip"
GZIP="$(which gzip)"
Set variable OS to the name of the operating system, ie. "Linux"
OS=$(uname -s)
Set variable OS to the name of the operating system, ie. "Linux"
OS=`uname -s`
(GNU specific) Set variable OUTPUT to full process info of process currently taking the most CPU time.
OUTPUT=`top -b -n 1 | tail -n +8 | head -n 1`
Set variable PacketLoss to first digit of percentage of packet loss occurring when pinging host specified by TestIP
PacketLoss=$(ping "$TestIP" -c 2 | grep -Eo "[0-9]+% packet loss" | grep -Eo "^[0-9]")
Set variable PING to 1 if it's possible to ping host ADDRESS, to 0 otherwise.
PING=$(ping ADDRESS -c 1 | grep -E -o '[0-9]+ received' | cut -f1 -d' ')
set variable r to currently running kernel release, ie. 4.4.0-81-generic
r="$(uname -r)"
Set variable value to current kernel release name.
value=$(uname -r)
show a count of the number of filenames ending in .txt in the current directory, without descending into sub-directories
find . -maxdepth 1 -name \*.txt -print0 | grep -cz .
Show a long listing of files not modified in over 20 days or not accessed in over 40 days
find /mydir \(-mtime +20 -o -atime +40\) -exec ls -l {} \;
Show a long listing of the latest file or directory under current directory
ls -lrt | tail -n1
show all the ".acc" files in the folder /home
find /home -type f -name '*.aac'
show all the ".flac" files in the current folder and do not search in the sub directories
find . -maxdepth 1 -type f -name '*.flac'
show all .cpp, .c, .h, .hpp files in the folder ~/src
find ~/src -type f \( -iname '*.cpp' -or -iname '*.h' -or -iname '*.c' -or -iname '*.hpp' \) -exec echo {} \;
show all the directories in the current folder
find . -type d
show all directories in the current folder excluding those that are present in the sub directories of media, images and backups
find . -type d \( -name media -o -name images -o -name backups \) -prune -o -print
show all directories in the current folder excluding those that are present only in the paths ./media, ./images and ./backups
find . -path './media' -prune -o -path './images' -prune -o -path './backups' -prune -o -print
Show all files in /etc that are owned by root have been modified within the last minute
find /etc/ -user root -mtime 1
show all files in /usr/tom and display only files ending with ".pl" or ".pm"
find /usr/tom | egrep '*.pl| *.pm'
show all files in the current directory and all subdirectories
find .
show all files in the current directory and all subdirectories
find . -print
show all the files in the current folder excluding those from the directories whose name starts with "git"
find . -type d -name '.git*' -prune -o -type f -print
show all the files in the entire file system which are bigger than 1.1GB
find / -size +1.1G
show all the files in the entire file system which are bigger than 100MB
find / -size +100M
show all the files in the folder /etc which have been modified in the last 24 hours
find /etc -mtime -1
Show all files in user's home directory that have read, write and execute permissions set for user, group and others.
find ~ -perm 777
Show all files that have not been accessed in the $HOME directory for 30 days or more
find $HOME -atime +30
show all the regular files in current folder
find . -type f -print0
show all regular/normal the files in the current folder whose size is bigger than 0 bytes excluding everything
find * -prune -type f -size +0c -print
show all the regular/normal files in the folder /home/user/demo
find /home/user/demo -type f -print
Show all running processes with a name matching "postgres"
ps -ef | grep postgres
Show all values (without the names) of variables whose name or value contains "VARIABLE_NAME"
myVariable=$(env | grep VARIABLE_NAME | grep -oe '[^=]*$');
Show all variables whose name or value contains "PATH", sorted in reverse alphabetical order.
env | uniq | sort -r | grep PATH
Show the current UTC date in '%Y-%m-%dT%k:%M:%S%z' format
date -u '+%Y-%m-%dT%k:%M:%S%z'
Show the date in default format for tomorrow + 2 days + 10 minutes
date -d tomorrow+2days-10minutes
Show directory sizes in KB and sort to give the largest at the end
du -sk $(find . -type d) | sort -n -k 1
Show directory sizes in KB and sort to give the largest at the end
find . -type d -exec du -sk {} \; | sort -n -k 1
show the disk use of all the regular/normal files in the current folder which are bigger than 50MB
find . -type f -size +50000k | xargs du -sh
show the disk use of all the regular/normal files in the file system which are bigger than 100MB
find / -type f -size +100M | xargs du -sh
Show the epoch in default date/time format
date -ud@0
Show the explanation of find's debugging options
find -D help
Show files in /home owned by group `test'
find /home -group test
Show the files or directories in the current directory whose names are not "MyCProgram.c"
find -maxdepth 1 -not -iname "MyCProgram.c"
Show file type information for all regular files under '/home' directory tree
find /home -type f -exec file {} \;
Show file type information for files in /usr/bin
find /usr/bin | xargs file
Show filename and filetype description of all PHP files in all directories contained in current directory whose name or filetype description includes "UTF"
file */*.php | grep UTF
Show filename and filetype description of all PHP files in current directory whose name or filetype description includes "UTF"
file *.php | grep UTF
Show find's version
find --version
Show human-readable file type description of file "/mnt/c/BOOT.INI"
file /mnt/c/BOOT.INI