nl
stringlengths
13
387
bash
stringlengths
1
532
Locate all files named 'restore.php' in the current directory and 3 levels below
find . -maxdepth 4 -name 'restore.php'
Locate all the hard links of file `passwd'
find / -samefile passwd
Locate all OGG files that reside in the home directory and have not been accessed in the past 30 days
find $HOME -iname '*.ogg' -atime +30
Locate and rename unprintable directories using inode numbers
find . -inum 211028 -exec mv {} newname.dir \;
Locates bzip2 command in a system.
which bzip2
Locate file "file1"
find -name file1
Locate files that reside in the /u/bill directory tree and were last accessed between 2 and 6 minutes ago
find /u/bill -amin +2 -amin -6
Locate files whose status was changed less than 1 day ago
find . -ctime -1 -print
Locate the httpd.conf file on the system
find / -name httpd.conf
Locating large files (> 100 MB) in /home/ for 'cleaning'
find /home -type f -size +100M -delete
locate large files (> 100 MB) in /home/ for 'cleaning'
find /home -type f -size +100M -delete
locate large files (> 100 MB) in /home/ for 'cleaning'
find /home -type f -size +100M -print0 |xargs -0 rm
Locate logo.gif in the /var/www directory tree
find /var/www -name logo.gif
Locate OGG files under the home directory larger than 100 megabytes
find $HOME -iname '*.ogg' -size +100M
Locate OGG files under the home directory smaller than 100 megabytes
find $HOME -iname '*.ogg' -type f -size -100M
Locate symbolic links in /usr and below
find /usr -type l
Locate symlinks in directory trees lpi104-6 and research/lpi104-6
find lpi104-6 research/lpi104-6 -type l
Locate world-writable files and directories on the system
find / -path /proc -prune -o -perm -2 ! -type l -ls
Log in as "middleuser" with key "./middle_id.pem" and forward port 22 on host "middle.example.org" to port 2222 on localhost
ssh -i ./middle_id.pem -R 22:localhost:2222 middleuser@middle.example.org
Log in using key file "./device_id.pem" as user "deviceuser" on host "middle.example.org" and port 2222
ssh -i ./device_id.pem -p 2222 deviceuser@middle.example.org
Log into "ubuntu@ec2-XX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com" using identity file "~/path/mykeypair.pem"
ssh -i ~/path/mykeypair.pem ubuntu@ec2-XX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com
login as user postgres
sudo su -l oracle
login as user root
su -l
Login in 'whatever.com' as user 'whoever' with X11 forwarding to enable GUI programs on remote to be run
ssh -X whoever@whatever.com
Login to "$HOST" and create file "$FILE_PATH" if it does not exist
ssh -q $HOST "[[ ! -f $FILE_PATH ]] && touch $FILE_PATH"
Login to "host" using identity file "id_rsa"
ssh -i id_rsa host
long list al the files in the current directory which have all the permissions
find . -perm 777 -type f -exec ls -l {} \;
long list al the files in the current directory which have only read permission to the group
find . -perm 040 -type f -exec ls -l {} \;
long list al the files in the current directory which have read permission to the group
find . -perm -g=r -type f -exec ls -l {} \;
Look for "testfile.txt" in the "/" directory and 1 level below
find / -maxdepth 2 -name testfile.txt
Look for `regexp' in binary files
find . -type f -print|xargs file|grep -i text|cut -fl -d: | xargs grep regexp
Look for *.jpg files
find . -name “*.jpg”
Look for *.jpg files on the system
find / -name “*.jpg”
Look for *log files in directories at least three levels down the directory tree
find / -mindepth 3 -name "*log"
Look for *log files in directories at most three levels down the directory tree
find / -maxdepth 3 -name "*log"
Look for all files whose names match pattern 'my*'
find / -name 'my*'
Look for any files that have not been modified in the last two days
find -mtime +2
Look for any files that were modified 2-5 days ago
find -mtime +2 -mtime -5
(Linux specific) Look for any instance of "HIGHMEM" in the current kernel's compile-time config file.
grep “HIGHMEM” /boot/config-`uname -r`
(Linux-specific) Look for any instance of "ds1337" in the modules.alias file matching current kernel release
grep ds1337 /lib/modules/`uname -r`/modules.alias
Look for directory `Cookbook'
find -name Cookbook -type d
Look for file `Chapter1' under /usr and /home
find /usr /home -name Chapter1 -type f
Look for files in the current directory tree to which the group users have full access
find . -perm -070 -print
Look for files that have SUID or SGID set
find / -perm +6000 -type f
Look for files whose names begin with letters a-j
find / -name "[a-j]*" -print
Look for files with the name 'search' under current directory
find . -name "search"
Look for files with wide open permissions
find . -type f -perm 777 -exec ls -l {} \;
Look for files with wide open permissions
find . -type f -perm a=rwx -exec ls -l {} \;
Look for regular files in the directory trees 'deferred', 'active', 'maildrop', 'incoming' under /var/spool/postfix/
find /var/spool/postfix/{deferred,active,maildrop,incoming}/ -type f
Look for SGID files and directories
find / -perm /g=s
Look for SUID files and directories
find / -perm +4000
Look in /home/dm and below for files with 'uniform' in their names
find /home/dm -name "*uniform*"
Look in the current directory and below for all files whose names begin with either "my" or "qu"
find . \( -name "my*" -o -name "qu*" \) -print
Look up for 'myip.opendns.com' in server 'resolver1.opendns.com' and save the terse output in 'IP' variable
IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
Lookup information for user "vivek"
finger vivek
Lookup information of the current user
finger `whoami`
Make "bar" executable
chmod +x bar
Make "file.sh" executable
chmod +x file.sh
Make $WEEKS_TO_SAVE+1 directories named "weekly.N" where N ranges from 0 to "$WEEKS_TO_SAVE"
mkdir -p $(seq -f "weekly.%.0f" 0 $WEEKS_TO_SAVE)
Make 3 directories named "$HOME/Labs/lab4a/folder" followed by a 3 width zero padded number from 1 to 3
mkdir $(seq -f "$HOME/Labs/lab4a/folder%03g" 3)
Make 999 folders one inside another where first 998 of them is named as "folderX" where X goes from 1 to 998 and the last folder named as "folder9991000"
mkdir -p folder$( seq -s "/folder" 999 )1000
Make a copy of the entire contents of dir1 in the Pictures directory located in the user's home directory.
cp -r dir1/ ~/Pictures/
Make a copy of file.txt in all directories in current directory - names may not contain spaces.
ls -d */ | xargs -iA cp file.txt A
Make a copy of file1 in dir1, dir2, and dir3.
echo dir1 dir2 dir3 | xargs -n 1 cp file1
Make a new directory "new-dir" in every directory in the current directory tree
find . -type d | xargs -I "{x}" mkdir "{x}"/new-dir
Make a new directory "new-dir" in every directory in the current working directory non-recursively
find . -maxdepth 1 -type d | xargs -I "{x}" mkdir "{x}"/new-dir
Make a POST request to "http://dweet.io/dweet/for/cycy42" with data "PiIP" set to the IP address of the system
wget --post-data="PiIP=$(hostname -I)" http://dweet.io/dweet/for/cycy42
Make all the bugzilla subdirectories permission 775
find bugzilla -type d -exec chmod 775 {} \;
Make all directories in the current directory tree accessible to anybody
find . -type d -print0 | xargs -0 chmod go+rx
Make all regular files in the current directory tree world-readable
find . -type f -print0 | xargs -0 chmod go+r
Make directories "./es/es_MX.utf8/LC_MESSAGES" as needed and do not error if it exists
mkdir --parents ./es_MX.utf8/LC_MESSAGES
Make directory "/cpuset"
mkdir /cpuset
Make directory "/data/db"
sudo mkdir /data/db
Make directory "/etc/cron.15sec"
mkdir /etc/cron.15sec
make directory "/etc/cron.15sec"
mkdir /etc/cron.15sec
Make directory "/etc/cron.5minute"
mkdir /etc/cron.5minute
Make directory "/etc/cron.minute"
mkdir /etc/cron.minute
Make directory "/path/to/destination"
mkdir /path/to/destination
Make directory "/tmp/googleTestMock"
mkdir /tmp/googleTestMock
Make directory "/tmp/imaginary/" on remote host before archiving "file" to "user@remote:/tmp/imaginary/"
rsync -aq --rsync-path='mkdir -p /tmp/imaginary/ && rsync' file user@remote:/tmp/imaginary/
Make directory "/tmp/new"
mkdir /tmp/new
Make directory "/var/svn"
sudo mkdir /var/svn
Make directories "3/foo", "3/bar", and "3/baz"
mkdir 3/foo 3/bar 3/baz
Make directories "Labs/lab4a/folder1", "Labs/lab4a/myfolder", and "Labs/lab4a/foofolder"
mkdir Labs/lab4a/{folder1,myfolder,foofolder}
Make directory "TestProject"
mkdir TestProject
Make directories "a", "b", "c", "d", and "e"
mkdir a b c d e
Make directories "a/b/c" as needed without causing an error if it exists
mkdir -p a/b/c
Make directory "aaa"
mkdir aaa
Make directory "aaa/bbb"
mkdir aaa/bbb
Make directory "alpha_real"
mkdir alpha_real
Make directory "backup"
mkdir backup
Make directory "certs"
mkdir certs/
Make directory "destdir"
mkdir destdir
Make directory "dir" and do not cause an error if it exists
mkdir -p dir
Make directory "dir1"
mkdir dir1
Make directory "dirname" with permissions set to 777
mkdir -m 777 dirname
Make directories "es/LC_MESSAGES" as needed and do not error if it exists
mkdir -p es/LC_MESSAGES
Make directory "foo"
mkdir foo
Make directories "foo" and "bar"
mkdir foo bar
Make directory "foo" and do not cause an error if it exists
mkdir -p foo