Find, View and Delete Files and Directories Using Linux Commands

Most basic Linux file and directory management – creating, renaming, moving and copying – can be achieved with the use of just three Linux commands. Their use is fairly straightforward, though it’s probably a good idea to be reasonably familiar with the Linux directory structure before getting too adventurous with file work (or download Knoppix to test drive Linux). To rename a file, we use the mv command, giving two arguments. The first is the current name of the file, and the second is the name to change the file to. $ mv oldname.txt newname.txt Here the file oldname.txt is renamed to newname.txt. The same absolute and relative rules apply when addressing files here, so the file oldname.txt has to be in the current working directory. Moving a file is achieved using the same command. $ mv something.txt newplace/something.txt This will move the file something.txt from the current directory to the directory newplace. The directory has to exist, and we’ll look at creating directories in a moment. It might be worth pointing out that using the mv command can achieve both moving a file and renaming it at the same time, like this. $mv oldname.txt newplace/newname.txt So we come to copying files. This is done using the cp command. $ cp this.txt there.txt In this example the file this.txt is copied to file there.txt. This is extremely useful for creating backups of files before editing them. The convention in this case is to use a .BAK extension. $ cp important.txt important.txt.B In this last part of our brief run through of basic Linux commands for directory structure and manipulation,...

Pin It on Pinterest