10 Linux Commands To Manage Files Easily

This Post is a list of Linux commands to manage files in Linux distros. Handling files on Linux is as easy as in any other OS. The file manager is there for rescue but where is the fun in that. Linux is an OS that most of use with the command line.

Here you get familiar with how commands rather than using few clicks to get things done. Moreover, you can do more things with commands than a GUI interface.

This brings us to the question, of how we can use the terminal to manage files. In this article, I will show you how you can manage files in Linux using terminal commands. there are a lot of Linux commands for this purpose but this post will short out the best of them

Linux commands to manage files

Here is the list of commands to manage files on your Linux Machine. Here we will see how you can copy, move, delete, rename, or move files using commands in Linux.

linux commands to manage files

CD Command

This is the most common and important command in Linux. It is used to set the default directory so you don’t need to type in the whole file address again and again. All you need to do is type cd and then directory name in the terminal.

cd folder name

To go back to the previous default directory

cd /

You can also use this command to move into two or more folders inside the root folder.

cd  folder a/folder b

LS command

You cannot manage files unless you know what are you working with. This command list all the file and folder within the directory you are working on currently. To use, go to the terminal then desired directory and ty ls, and hit enter.

ls

Here are the attributes you can use with this command

  • --version to show the version of the command.
  • -l to show information like size, path, etc of the files list.
  • -a shows hidden files
  • -LS short files according to their size.
  • lh show files size in KB, MB, and GB instead of bytes.
  • -r Display files in reverse order.

DIR command

This Linux command displays directories. in the current directory. Simply type dir in the terminal and hit enter.

dir

You can use these attributes with this command

--version showing the version of the dir command.

-A To display all files including hidden files in the current directory.

-l shows files with their author.

-a display all files within the current and previous directory.

f open files with a certain extension.

MV command

Linux commands mv stands for the move but you can do a whole lot more than move. As it sounds, it can move a single or group of files and folders to the target directory. you can use these commands without the need of creating a destination directory first. It will be created if not present. Moreover, it can also rename files or folders. Here is how you can use it.

  • To use rename a file
mv oldfilename.txt newfilename.txt
  • To move a file.
file_or_folder /destination-directory

Here are the attributes to use with the mv command

  • --version gives the version of the current mv command installed.
  • -i ask for user confirmation.
  • -f overwrite the destination file
  • -b take a backup of the file

CP command

As the syntax might suggest, this command is used to copy data from one file or folder to another. as shown below.

cp file1 file2

you can also use this command to copy data from folders. just enter the source and destination folder.

RM command

Rm command deletes the file you are working with. To use this command:

rm filename

GREP command

With the Grep command, you can search specific patterns within a file. This command comes in handy when forgetting something important in a file and can’t find it afterward.

grep {search_string} {file}

For example.

grep  bhanu filename
  • -i is used to ignoring case sensitive
  • -v is used to exclude the lines which match the given search quarry.
  • -w is used to print the lines in which given quarry matches.

ZIP command

Next in the list of Linux commands is zip. As we all know, zip is file compression format and that is what exactly this command does. You can use this command to compress files and free some space.

zip zip_file_name.zip filename
  • You can also compress multiple files into a single file

zip filename.zip file1 file2 file3 file4

  • To decompress file
unzip zip_file_name.zip

PWD command

This is the easiest of all the Linux commands on the list. Its work is also a simple task. Pwd displays the path for the current directory you are in.

pwd

CAT command

The main task of cat commands is to show you the content of a file. moreover, it can also be used to create a file with no extension. Here is how you can use different cat Linux commands.

  • To show the contents of a file
cat filename.txt 
  • Create new file
cat >filename
  • Display multiple files
cat file1 file2
  • Add $ at the end of every line in a file.
cat -e filename
  • Show the output of the file in a new file. If the file already exists then the output will be shown in that file.
cat fileold > filenew
  • adding contents of multiple files in one file
cat file1 file2 > newfile

So these are the Linux commands you can use to manage files in Linux distros.