Managing files using the command line 

A file manager is good for many things but there are times when it is easier and faster to use the command line and in some cases it may be the only option. While the following commands alone will not seem that amazing at first as you use them more and learn the tricks to using them you will find yourself using them more and more and start to unlock the real power behind the command line.

To list files and directories  in a selected directory all that is required is the ls command.

ls <directory>

or if you also want to see hidden files

ls -A <directory>

the following lists all the files and folders that are not hidden in the Documents/work/ directoriy

ls Documents/work/

Moving and renaming of files are both handled by one simple command, to move files use this command.
mv <file> <new directory>

to move multiple files list them before the new directory like this

mv <file1> <file2> <file3> <new directory>

below is an example of moving two files to the Documents/  directory

mv file1.txt file2.txt Documents/

or if you want to rename a file

mv <file> <new file>

an example of this is

mv file1.txt file-renamed.txt
Remember that when listing files you must include the path to the file such as </path/to/file.pdf>. Also the directory you are moving files to must already exist or you will get an error.

When moving files around a very useful command is mkdir which as the name suggests makes directories.

mkdir <new directory>


mkdir Documents/work/important/

Finally removing files can be achieved using rm. This is a command you need to be careful when using as there is no trash with this command for recovering deleted items so if you delete something it is gone so when deleting a file make sure it is one you want deleted.

rm <file>

or to delete multiple files

rm <file1> <file2> <file3>

if I wanted to delete a file named file2.txt in the Documents directory iI would use

rm Documents/file2.txt

This should be enough to get you started managing files but if you want to learn more about the commands shown here or other you can use this to find information in the command

man <command>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s