Finding a file containing a string in a given folder
1 |
grep -r 'search string' * |
Searching the output of a given command for a string
1 |
ps aux | grep 'apache2' |
Scrolling through the output of a command
1 |
ps aux | less |
Opening a file as read-only in VIM
1 |
vim -R "file name" |
Print the current working directory
1 |
pwd |
Switching to root using sudo
1 |
sudo su - |
Install a package
1 |
apt-get install "package-name" |
Getting the contents of a file
1 |
cat "file name" |
Getting the first 100 lines of a file
1 |
head -n 100 "file name" |
Getting the last 100 lines of a file
1 |
tail -n 100 "file name" |
Finding a given file using the current directory as a starting point
1 |
find . -name "file name" |
List all the files in a directory, human readable, and sort by modified time
1 |
ls -halt |
List the files with a given extension
1 |
ls *.php |