In my experience, the more I used my command line the more I understood how my computer works. It is easy to see where things are and to get organized. I just love it! I am currently using PowerShell 7, which is different from Windows Powershell. In most cases Powershell 7 can use the same commands as Bash.
COMMAND | POWERSHELL 7 | BASH |
current directory | pwd | pwd |
change directory | cd | cd |
make directory | mkdir | mkdir |
new file | ni | touch |
copy | cp | cp |
delete | del | rm |
remove directory | rmdir | rmdir |
move | mv | mv |
list items | ls | ls |
rename | rename-item | mv |
One thing I did was spent time moving around inside of my file system, and organizing things in a way that works for me. I cleaned up my system by deleting, moving and copying files. This is an ongoing project, but I am pretty pleased with how clean and organized everything is. There are no lost and hidden files that I have forgotten about clogging up my storage.
Most of the commands above need more, like a file or directory to act on. All of the commands above have different options and modifiers to make them more useful. Below I will show some simple examples of every day uses of the command line. Once you get the hang of these things then you can expand your knowledge as needed.
cd on it’s own, takes you to your home directory.
cd ..
moves up two directories and etc.
cd ../..
cd path moves you to the specified directory. You can just name the folder you want if it is contained in the current directory, otherwise you have to show the path to the directory you want. Both are shown below. The third example is always valid, showing the complete path from c:
cd folder-name
cd desktop/folder-name
cd c:/users/user-name/desktop/foldername
mkdir new-folder
#in POWERSHELL
ni file.txt
# in BASH
touch file.txt
Finally some examples of moving, copying and renaming files. You use the command followed by the file name, then the destination folder and it's path.
mv file.txt c:/users/user-name/destination-folder
cp file.txt c:/users/user-name/destination-folder
#rename in Powershell
rename-item file.txt new-name.txt
#rename in Bash
mv file.txt new-name.txt
In Powershell you can clear the recycle bin from the command line!
clear-recyclebin
You will be prompted if you want to clear all the folders in the recycle bin, just hit enter for yes and the recycle bin will be cleared!