Difference between revisions of "Using Linux - Files and Directories"

From Computer Science
Jump to: navigation, search
(Basic Commands)
Line 1: Line 1:
''This page is a part of the [[Linux and CS Systems Bootcamp]].  This page assumes you have your computer setup to connect to the CS server, or have the appropriate software installed on your computer to run commands.  Go back to the Linux and CS Systems Bootcamp main page if you don't have our system setup yet.''
+
''This page is a part of the [[Linux and CS Systems - Getting Started]].  This page assumes you have your computer setup to connect to the CS server, or have the appropriate software installed on your computer to run commands.  Go back to the Linux and CS Systems Getting Started main page if you don't have our system setup yet.''
  
 
=Basic Commands=
 
=Basic Commands=

Revision as of 16:18, 10 January 2020

This page is a part of the Linux and CS Systems - Getting Started. This page assumes you have your computer setup to connect to the CS server, or have the appropriate software installed on your computer to run commands. Go back to the Linux and CS Systems Getting Started main page if you don't have our system setup yet.

Basic Commands

With the terminal you can create, copy, move, and delete files and directories. The following are the most important commands to do this.

  • cd - change directory
  • mkdir - make a new directory
  • ls - list directory contents (use option -l to see details)
  • cp - copy files
  • rm - remove files (be careful, there is no recycle bin or trash - once you delete, it's gone)
  • rmdir - remove directory
  • mv - move or rename a file or directory
  • nano - simple text editor

Sample Session

Here is a transcript of the use of these commands on the CS server, showing how they work and what is printed on the screen. Note that the part after the "cs299@cs:~> " is the part that was typed by the user - so the user first typed "pwd" and then enter, the system printed "/u1/class/cs299", and the system then printed the prompt "cs299@cs:~> " and waited for the user to type the next command. You can also watch a [video demo].

cs299@cs:~> pwd
/u1/class/cs299
cs299@cs:~> mkdir new-dir1
cs299@cs:~> mkdir new-dir2
cs299@cs:~> nano hello.txt
cs299@cs:~> ls
bin/  hello.txt  new-dir1/  new-dir2/  proto/
cs299@cs:~> cp hello.txt new-dir1
cs299@cs:~> cp hello.txt new-dir2/hello2.txt
cs299@cs:~> ls new-dir1
hello.txt
cs299@cs:~> ls new-dir2
hello2.txt
cs299@cs:~> mv new-dir2 new-dir3
cs299@cs:~> ls
bin/  hello.txt  new-dir1/  new-dir3/  proto/
cs299@cs:~> rm hello.txt 
cs299@cs:~> ls
bin/  new-dir1/  new-dir3/  proto/
cs299@cs:~> rmdir new-dir3
rmdir: failed to remove 'new-dir3': Directory not empty
cs299@cs:~> rm new-dir3/hello2.txt 
cs299@cs:~> rmdir new-dir3
cs299@cs:~> ls
bin/  new-dir1/  proto/