Command Line hands-on


  • Clear history: `ctrl + l`


  • Get the current path: `pwd`


List directory contents: ls

List all directory contents: ll

List all directory contents sorted by time edited: ls -alt

List directory (wildcard matching): ls *.txt

List all files of type: find . -name "*.txt" -print

Go back to the previous directory: cd — or cd ..

Make (empty) directory: mkdir sample-dirname

Remove (empty) directory: rmdir sample-dirname

Remove the directory with all contents: rm -rf sample-dirname/

Remove directory contents and keep directory: rm -rf *

Checkout directory: cd sample-dirname

Browsing directories: pushd sample-dirname / popd / dirs (see


  • Use the `-R` option to change permissions recursively.

WordPress Files/Folder Permissions

Let apache be owner: chown www-data:www-data -R *

Change directory permissions rwxr-xr-x: find . -type d -exec chmod 755 {} \;

Change file permissions rw-r — r — : find . -type f -exec chmod 644 {} \;



Create symlink: ln -s source-dirname destination-dirname

Update symlink: ln -sfn source-dirname destination-dirname

Remove symlink: unlink sample-dirname

  • -s: Create a symbolic link.


Make (empty) file: touch sample-filename.txt

Change creation date: touch –t 201401011337 sample-filename.txt

Change modified date: touch –mt 201401011337 sample-filename.txt

Duplicate file: cp sample-filename.txt sample-filename-copy.txt

Copy/Page folder with content: cp -a folder/ new_folder

Move/Rename file: mv current-filename.txt new-filename.txt

Move/Rename the file and prompt before overwriting an existing file: mv -i current-filename.txt new-filename.txt

Remove file: rm sample-filename.txt

View file: less sample-filename.txt / more sample-filename.txt

Write to file (will overwrite existing content): cat > sample-filename.txt (quit with ctrl+d)

Search for a filename (not content!) in the current directory: find sample-filename.txt

Search for a string (not filename!) inside all files in the current directory: ack "string" --php (documentation)

Search for a string inside all files in the current directory and subdirectories: grep -r "string" *

Search and replace within the file: sed -i '' 's/original-text/new-text/g' sample-filename.txt

MD5 hash for files: md5 sample-filename.txt

MD5 hash for folders: tar c folder | md5sum

Encrypt file: openssl enc -aes-256-cbc -e -in sample-filename.txt -out sample-encrypted.txt

Decrypt file: openssl enc -aes-256-cbc -d -in sample-encrypted.txt -out sample-filename.txt


Access via ssh: ssh pi@

Copy file from server to local: scp pi@ ~/Desktop/ (use -r to recursively get complete folder)

Copy file from local to server: scp ~/Desktop/file.png pi@ (use -r to recursively get complete folder)

Copy file from local to server: rsync --exclude=".DS_Store" -vzcrSLh ~/Desktop/file.png pi@

Escape files with spaces in the name like this: /path/to/file\\\ name.png


Show disc space: df -h

Show disc space (inodes): df -i

Show disc space for current directory: du -hs

Current processes (also CPS usage): top or htop

Show running PHP processes: ps aux | grep php

Monitor error log (stream as the file grows): tail error.log -f -n 0


Start application: open -a [name-of-programm] e.g. open -a firefox

Open finder with current folder: open .


Register variable: export TESTING="Sample Text"

Echo variable: echo $TESTING

Unset variable: unset TESTING

Output & Redirects

Write to file: echo "Hello" > hello.txt

Append content from a file to another file: cat file1.txt >> file2.txt

Add the number of lines, words, and characters to file2.txt: cat file1.txt | wc | cat > file2.txt

Sort the content of a file (like cat): sort hello.txt

Save to sorted content to a new file: cat file1.txt | sort > sorted-file1.txt

Sort and remove duplicates and save them to a new file: sort file1.txt | uniq > uniq-file1.txt


Calculate (returns only int): echo $((123/2))


Check site feedback: ping

Show site IP: dig +short

Show A Record: dig a (Returns: 43 IN A aka public-name ttl internet record-type server-address)


Curl headers: curl -I



Installation: brew install tree


Installation: brew install httpie


http GET https://hofmannsven.test --verify=no


Fix OpenSSH Client Bug:

Signing off:

Akshay Prasad

I am Master's student in the Netherlands and has a previous work experience of 4 years in the field of Software Development.