Linux 4 Windows
Learn And Run Linux On Your Windows Computer

This Linux 4 Windows Tutorial shows you how to create and access directories and copy, move and delete Damn Small Linux files on your Windows computer. You will use the Beaver text editor and apply the mkdir, cd, cp, mv, and rm commands and some command options.

Creating Directories, Copying, And Moving Damn Small Linux Files

This tutorial shows you some basic directory and file processing commands for Damn Small Linux.


Step 1 Access the Beaver Editor (via Apps and then Editors) and create four files with the following names: File1.txt, File11.txt, File12.txt, and File12 (there's no .txt at the end of the last file name.) Remember to give each file simple but not misleading contents. Use the ls command and the pwd command to verify the directory contents and location as shown in Figure 1.

Linux file tutorial 3 Figure 1

Damn Small Linux File Tutorial 3 Figure 1
We start with four files.



Step 2 Enter the mkdir backup command to create a directory called backup. This command does not change the working directory as shown by the first pwd command. To change the working directory enter the cd backup command, which actually changes the working directory. These commands are shown in Figure 2.

Linux file tutorial 3 Figure 2

Damn Small Linux File Tutorial 3 Figure 2
Creating a directory and making it the working directory.



Step 3 Enter the cd .. command which takes you from the child (backup) directory to the parent directory, /home/dsl. Don't forget the space (or spaces) after the cd. Linux is sometimes as picky about spaces as it is about lower-case and upper-case letters.

Step 4 Enter the cp *.txt backup command which copies only the files with the txt extension to the backup directory. The ls backup command lists the contents of the backup directory. The ls command lists the contents of the working directory which includes the Events.cal file and the backup directory shown on my screen in blue. The results appear in Figure 3.

Linux file tutorial 3 Figure 3

Damn Small Linux File Tutorial 3 Figure 3
Copying selected files.



Step 5 Starting from the /home/dsl directory create the backup2 directory. Enter the mv *.txt backup2 command which moves the files with the txt extension to the backup2 directory. List the contents of appropriate directories. The results are shown in Figure 4.

Linux file tutorial 3 Figure 4

Damn Small Linux File Tutorial 3 Figure 4
Moving selected files.



Step 6 Position yourself in the backup2 directory and copy the files with the txt extension back into the /home/dsl directory, the source directory. Go into the Beaver editor and make changes to the File11.txt file. You can make this command interactive by adding -i option as in the following example: cp -i *.txt backup2 . This command prompts you whether or not you want to copy the file from the source directory into the destination directory (backup2). Enter y to copy the file, enter ncommand to skip copying the file. The results are shown in Figure 5.

Linux file tutorial 3 Figure 5

Damn Small Linux File tutorial 3 Figure 5
Copying files interactively.



Step 7 The rm command removes a file or a directory. But as we see the directory must not contain any files or directories to be removed with this simple command such as rm backup2. Use the -r option as shown in the rm -r backup2 command. (We hav already removed the backup directory.) The results are shown in Figure 6.

Linux file tutorial 3 Figure 6

Damn Small Linux File tutorial 3 Figure 6
Removing a non-empty directory







Exercises. It’s always a good idea to test your understanding by taking the tutorial a few steps further. (1) You can practice referring to directories by copying files from one brother to another; for example, from the backup directory to the backup2 directory. Hint.Use references such as /home/dsl/backup so Linux will be able to find your directories. (2) Create the backupa directory starting from the backup directory. Then repeat the above exercise copying from father (backup) to son backupa. Then copy from the son to the uncle i>backupa. (3) Test the -u option of the cp command which only copies those files that are newer. After all, sometimes you want the computer to make the copy-don't copy decision.