Command Line Interface Basics

The directory structure on your computer looks something like this

CLI Basics
In your CLI prompt, type pwd and press enter.
This will display the path to you’re working directory.
As you can see we get the prompt back after entering a command.
CLI Commands
CLI commands follow this recipe: command flags arguments
command is the CLI command which does a specific task
flags are options we give to the command to trigger certain behaviors, preceded by a –
arguments can be what the command is going to modify, or other options for the command
Depending on the command, there can be zero or more flags and arguments
For example pwd is a command that requires no flags or arguments
pwd displays the path to the current working directory
clear will clear out the commands in your current CLI window

ls lists files and folders in the current directory ls -a lists hidden and unhidden files and folders ls -al lists details for hidden and unhidden files and folders Notice that -a and -l are flags (they’re preceded by a -) They can be combined into the flag: -al

cd stands for “change directory” cd takes as an argument the directory you want to visit cd with no argument takes you to your home directory cd .. allows you to change directory to one level above your current directory

mkdir stands for “make directory” Just like: right click -> create new folder mkdir takes as an argument the name of the directory you’re creating

touch creates an empty file

cp stands for “copy” cp takes as its first argument a file, and as its second argument the path to where you want the file to be copied
cp can also be used for copying the contents of directories, but you must use the -r flag The line: cp -r Documents More_docs copies the contents of Documents into More_docs

rm stands for “remove” rm takes the name of a file you wish to remove as its argument

You can also use rm to delete entire directories and their contents by using the -r flag Be very careful when you do this, there is no was to undo an rm

mv stands for “move” With mv you can move files between directories
You can also use mv to rename files

echo will print whatever arguments you provide

date will print today’s date

pwd clear ls cd mkdir touch cp rm mv date echo


电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>