zshell (Source: Wikimedia commons) |
Despite its intimidating interface, using command line is actually quite intuitive. It was quite easy for me to learn. In essence, the user first inputs a command (hence the name "command line"), and then the computer executes the command and shows the output.
Not all command lines are the same, however. For my examples, I'll be using the classic "bash shell". So, on my bash shell, the command "echo hello world"
~/ $ echo hello world!
outputs
hello world!
on the computer. Although there are many command lines, their commands share pretty much the same properties. In their basic format, all commands in the command line are made of two parts:
1. The executable/program
2. The arguments/options/inputs
In my example above, I called the executable "echo" and used the string "hello world!" as the argument. The echo command just types back what you put in as the argument.
In addition to executing commands, the command line navigates around the filesystem of the computer. You can think of the command line as something like a person in a house, where the house is the computer itself. You can do stuff in your house to manipulate or interact with the house. Similarly, you can move to a different room in the house. Anytime you're on the command line, you're are somewhere in the filesystem of the computer.
The command "pwd" shows where I am in the command line.
~/ $ pwd
outputs for me
/home/Documents/
So, if I wanted to see whats in the current "room", or file "path", I would use the command "ls"
~/ $ ls
could show
foo.txt helloreader.cpp anyrandomfile anyrandomfolder
folderofhomework
You're now probably wondering "How do I change my location?". Well, dear reader, you use the command "cd". The argument for "cd" must be a folder of some sort.
~/ $ cd folderofhomework
The command does not output anything, but if you use "pwd" again, you can see that you've moved locations.
~/ $ pwd
/home/Documents/folderofhomework
Those are the basics of any command line interface. Depending on what shell or prompt you have available, the commands may be different.
One of the equivalents of the commands I used above for the "command prompt" on windows machines is "dir" to "ls". The command "cd" is the same. However, on the command prompt, there is no direct equivalent for "pwd". You have to use the command "
echo %cd%"
Any questions, comments? Post them below.
Commands for unix derived command lines (bash, mac terminal, cshell, etc.)
Commands for the command prompt on windows
How to get to the Command prompt on Windows
How to get to the "terminal" app on the Mac
No comments:
Post a Comment