Skip to content

Instantly share code, notes, and snippets.

@bkrauska
Last active November 21, 2016 08:55
Show Gist options
  • Save bkrauska/6629321 to your computer and use it in GitHub Desktop.
Save bkrauska/6629321 to your computer and use it in GitHub Desktop.
Unix Commands
// find all files by name in current and sub-directories
find -name "file.name"
// find all files by name case insensitive in current and sub-directories
find -iname "file.name"
// find all files by name not matching in current and sub-directories
find -not -name "file.name"
// find files by size
find ~ -size (+100M more than|-100M less than|100M exacty)
// show current directory
pwd
// got to last directory
cd -
// shutdown now
shutdown -h now
// shutdown in 10 minutes
shutdown -h +10
// reboot the system
shutdown -r now
// display disk size for director
du -hs [directory-path]
// display the disk space usage
df -h
// display the type of file system
df -T
// search current process for app
ps -ef | grep app_name
// stop a process
kill -9 ####
// remove file with confirmation
rm -f filename
// remove files and directories recusively
rm -r filename
// copy file preserving mode, ownership and timestamp
cp -p filename1 filename2
// copy file with confirmation before overwritting
cp -i filename1 filename2
// move file with confirmation
mv -i filename1 filename2
// verbose mode for move
mv -v filename1 filename2
// show contents of files
cat filename1 filename2 -n (shows line numbers)
// change file permissions
chmod permissions filename
// change ownership
chown -R (recursively) user filename
// change your password
passwd -d (disables password) (USERNAME)
// show network information
ifconfig -a
// display information about the system
uname -a
// find where a command is
whereis ls
// find out what a command is
whatis ls
// print the last lines of a file
tail -n # (last # of lines) -f (view in real-time) fiename
// set the system date
date -s "01/31/2010 23:59:53"
// sync hardware clock with system date
hwclock –systohc
hwclock --systohc –utc
// download file
wget -O filename (store in different filename) -c (continue incomplete download) -b (download in background) url
// download urls from file
wget -i download-urls.txt
// download all pdf's from website
wget -r -A.pdf http://url-to-webpage-with-pdfs/
// search file for string
grep "search string" filename
// search files for a string
grep "search string" filename.pattern
// search directory for string
grep -r "search string" .
// case insensitive file search
grep -i "search string" filename
// regex file search
grep "regex pattern" filename
// search file for full words, not sub-strings
grep -iw "search" filename
// display lines that do no match the search string
grep -v "search string" filename
// get a count of the matches
grep -c "search string" filename
// get only the filenames of the files that match
grep -l "search string" filename_*
// show the line numbers for the string matches
grep -n "search string" filename
// show all information about files/directories
ls -l
// show file size in human readable format
ls -lh
// sort results based on modified time
ls -lt
// sort results based on reversed modified time
ls -ltr
// list one file per line
ls -1
// show information about current directory
ls -ld
// show hidden files
ls -a
// show all files recursively
ls -R
// create new tar (uncompressed)
tar cvf archive_name.tar dirname/
// extract from tar
tar xvf archive_name.tar
// view tar
tar tvf archive_name.tar
// create new gzip tar (compressed)
tar cvzf archive_name.tar.gz dirname/
// extract a gzip tar
tar xvfz archive_name.tar.gz
// view gzip tar
tar tvfz archive_name.tar.gz
// add a file or directory to an existing tar
tar rvf archive_name.tar newdir/
// add a file or directory to an existing gzip tar
tar rvfz archive_name.tar.gz newdir/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment