0% found this document useful (0 votes)
83 views

Using The Linux Command Line

The document discusses basic Linux commands for navigating directories and manipulating files from the command line in a terminal. It explains commands like ls to list files, cd to change directories, mkdir to make directories, cp to copy files, rm to remove files, mv to move/rename files, and provides examples of how to use each command. It notes that while modern Linux systems have GUIs, programmers frequently use the terminal and these basic keyboard-based commands.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Using The Linux Command Line

The document discusses basic Linux commands for navigating directories and manipulating files from the command line in a terminal. It explains commands like ls to list files, cd to change directories, mkdir to make directories, cp to copy files, rm to remove files, mv to move/rename files, and provides examples of how to use each command. It notes that while modern Linux systems have GUIs, programmers frequently use the terminal and these basic keyboard-based commands.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Using the Linux Command Line

Using the Linux Command Line

The CS50 IDE is a cloud-based machine running


Ubuntu, one of the many flavors of the Linux OS.
Many modern Linux distributions have graphical
user interfaces (GUI) to allow easy mouse-based
navigation.
Still, as a programmer youll likely be using your
terminal window frequently, and you can do many
of the same tasks with keyboard commands.

Using the Linux Command Line

Lets have a look at some of the most important of


these keyboard-based commands for working
within the IDE or any UNIX-based system.

Using the Linux Command Line


ls

Short for list, this command will give you a readout of


all the files and folders in your current directory.

Using the Linux Command Line


cd <directory>

Short for change directory, this command change your


current directory to <directory>, which you specify,
in your workspace or on your operating system.
The shorthand name for the current directory is .
The shorthand name for the parent directory of the
current directory is ..
If ever curious about the name of the current directory,
though the terminal prompt will often tell you, you can
type pwd (present working directory).

Using the Linux Command Line


mkdir <directory>

Short for make directory, this command will create a


new subdirectory called <directory> located in the
current directory.

Using the Linux Command Line


cp <source> <destination>

Short for copy, this command will allow you to create a


duplicate of the file you specify as <source>, which it
will save in <destination>.
If you wish to copy entire directories, youll need to
modify the command slightly:
cp r <source directory> <destination directory>

The -r stands for recursive, and tells cp to dive down


into the directory and copy everything inside of it
(including any subdirectories it might contain).

Using the Linux Command Line


rm <file>

Short for remove, this command will delete <file>


after it asks you to confirm (y/n) you want to delete it.
You can skip the confirmation by typing:

rm f <file>
But use at your own peril! Theres no undo.

To delete entire directories you need to use the r flag,


just as was the case with cp.

rm r <directory>

You can also combine the r and f flags into rf.


Again, careful! Theres no undo!

Using the Linux Command Line


mv <source> <destination>

Short for move, this command will allow you to


effectively rename a file, moving it from <source> to
<destination>.

Using the Linux Command Line

To be sure, there are many more basic command


line utilities at your disposal, and well discuss
many of them in the future in CS50.
If you wish to explore other interesting ones before
we see them in the class, read up on:
chmod
rmdir
sudo

ln
man
clear

touch
diff
telnet

You might also like