Shell Basics

Home shortcut

    

~


    

Current directory shortcut

    

.


    

Parent directory shortcut

    

..


    

Print working directory

    

pwd


    

Print text

    

echo "Hello world"


    

Change directories

    

cd folder-name


    

Move into user directory

    

cd ~


    

Move up a directory

    

cd ..


    

Move up multiple directories

    

cd ../..


    
    

cd ../../..


    

List files and folders

Options:

  • -1: List in one column
  • -A: Include hidden folders
  • -F: Add slash to end of folders
  • -G: List with colors
  • -l: List in long format
    

ls


    
    

ls folder-name


    
    

ls folder-1 folder-2


    

Create file(s)

    

touch file-name.txt


    
    

touch file-name-1.txt file-name-2.txt


    

Create folder(s)

    

mkdir folder-name


    
    

mkdir folder-1 folder-2


    

Create intermediate folders

    

mkdir -p folder-1/folder-2


    
    

mkdir -p folder-1/folder-2/folder-3


    

View file contents

    

cat file-name.txt


    
    

less file-name.txt


    

View file contents (with line numbers)

    

cat -n file-name.txt


    
    

less -n file-name.txt


    

Learn more about a command

    

man command