DEV Community

Cover image for Useful Bash/Terminal Commands
Hillary Nyakundi
Hillary Nyakundi

Posted on

Useful Bash/Terminal Commands

These are the basic commands for navigating directories in a Terminal or Git Bash window

Moving in directories

Change Directory

cd [path/to/desired/directory]

Change to Home Directory

cd ~

Move to One Directory Up

cd ..

View Folders and Files in the Directory

ls

Show the current Directory

pwd

Autocomplete a File Name in the Current Directory

Press tab key once to autocomplete once you have typed a unique portion of a file name.

File Manipulations

Make New File

touch [name of file to create]

Make New Folder

mkdir [name of directory to create]

Delete file

rm [name of file to remove]

Delete folder

rm -r [name of directory to remove]

Copying File

cp [filename1] [filename2]

Move/Rename File

mv [filename1] [filename2]

Mac Only

Open file or folder (Mac only)

open [name of file]

Open all files and folder in current directory (Mac only)

open .

PC Only

Open file or folder (PC only)

explorer [name of file]

Open all files and folder in current directory (PC Only)

explorer .

Top comments (1)

Collapse
 
preciouschicken profile image
Precious Chicken

I find rm a little bit scary - I've made mistakes in the past where I've deleted something forever without meaning to.

I use trash-cli now instead. Once installed it just means typing trash [name of file to remove] instead, which then puts it in your trash bin, rather than permanently deleting.