Command Line

Command line exercises

Drag Folder

Listing Directories

Change to the desktop. List all the directories on the Desktop.

$ cd ~/Desktop
$ ls -d */

More Listing

Change to the desktop. List all files and directories, 1 per line.

$ cd ~/Desktop
$ ls

Making Directories

Create a directory named demo.

$ mkdir demo

Making Deep Directories

Change to the desktop. Create the following directory structure using one command: demo/foo/bar/praxis

$ cd ~/Desktop
$ mkdir -p demo/foo/bar/praxis

Creating Files

Change to the demo folder. Create a file named hello.txt in the demo directory.

$ cd ~/Desktop/demo
$ touch hello.txt

Making, Moving, Deleting

Create a new folder called test_projects with three text files in it: test_1, test_2, test_3. Within test_projects, create another folder called files. Move the test files into the new directory. Move into the new directory to make sure it worked. Then delete the test_projects directory.

$ mkdir test_projects
$ cd test_projects
$ touch test_1.txt
$ touch test_2.txt
$ touch test_3.txt
$ mkdir files
$ mv test_1.txt files
$ mv test_2.txt files
$ mv test_3.txt files
$ cd files
$ ls
$ cd ..
$ rm -rf test_projects