Cover image for Don't fear the command line: Manipulation

Don't fear the command line: Manipulation

deniselemonaki profile image Dionysia Lemonaki ・3 min read

On my quest to stop being intimidated by the command line, the more I learn about it, the more fascinated I become by it.

In my last post ,which you can read here, I talked about the absolute basics anyone needs to get started using the terminal. But there is so much more you can do and in this post I'm going to dive deeper into not only viewing your filesystem in more detail but actually making changes to it.

You got options

We use ls to list the contents of the current directory, however , we can use ls with options which are usually preceded by the - character .Options modify and change the default behaviours of the commands they are paired with. Let me explain:

  • ls -a lists all contents of a directory, including hidden files and directories. Files starting with a dot . are hidden and are not displayed with using ls alone.
  • ls -l lists all contents of a directory in long format and displayed as a table. Each column represents access rights, hard links( number of child directories and files), the username ,the size of the file in bytes, the date and time the files were last modifies and the file's name.
  • ls -t orders files and directories by the date and time they were last modified.

Each option can be used separately or multiple options can be used together like -alt . In this case -alt lists all files and directories, including hidden ones in long format, ordered by the date and time they were last modified.

I like options

We can also use the command line to copy, move and remove files and directories


  • cp copies files and directories. To copy a file into a directory we use cp with the source file as the first argument and the destination directory as the second argument. If we have the file codingbooks.txt that's inside the Books directory and we want to copy it's contents into the Coding directory, then we would do :
 cp Books/codingbooks.txt Coding

To copy multiple files into a directory use cp with a list of the files sources as the first arguments and the destination directory as the last argument:

cp Books/codingbooks.txt Books/ruby.txt Coding


  • mv works in the exact same way as cp does. We use the file we want to move as the first argument and the destination directory as the second argument. In this case however, we can use mv to also rename files . Say we want to rename notes.txt to Notes.txt because we changed our mind and want for files to start with capital letters:
mv notes.txt Notes.txt

happy dance


  • rm removes files. In order to remove directories we use rm -r . The -r is an option that stands for recursive .It modifies the command, similar to what we talked about earlier on, and deletes the directory and child directories. For example,to delete the Pictures directory:
rm -r Pictures

Be careful when using these commands because once you delete the files or directories, they are permanently deleted! You will not be able to retrieve them from the Bin in the GUI.
it's gone


This one is the most powerful one in my humble opinion and the one that stood out to me the most. Using * we can select multiple groups of files and directories. Instead of spending lot's of time dragging and dropping files in the GUI or typing in the terminal, if we know we want to select many files of a certain type or that are located in a certain directory, we can use this instead. Below I have a few examples of it's use :

  • To list all files in the Documents directory, in long format, that end in .pdf
ls -l Documents/*.pdf
  • To copy all files that begin with m and end with .txt in the current directory, to the Documents directory
cp m*.txt Documents
  • To move all files in the working directory to the Pictures directory
mv * Pictures
  • To delete all files in the Downloads directory
rm Downloads/*

Those are some of the ways we can manipulate and alter the file system using the terminal.
If you have made it this far, you deserve a cat gif

Posted on by:


markdown guide

This was such a great read! Thank you so much! I even learned something new!! 😃
I really enjoy the way you write, Dionysia! It's such a pleasure to read, your gifs always make me grin and your explanations are so clear and easy to understand - I wish I had these articles when I first started out getting familiar with the command line! :) I can't wait to read more from you! 😊


Your comment made me day :)
Thank you so much for your support and the nice words you said to me. You are one of the kindest people I have come across.
Thanks again :)


Oh, of course! I absolutely mean it, it's always such a joy to see people being so genuinely interested and excited about code and tech and everything that comes along with it! I'm so glad that you decided to invest the time in writing out and sharing all your findings, so again, if anything, I thank you! 😅😊 I'm just stoked to -alt list everything from now on! 😄

This makes me so happy, yes -alt on everything from now on haha :)


#meta DEV tip

In my last post ,which you can read here, I talked about the absolute basics

using liquid tags to promote your previous posts gives it a bit more visual flair and breaks up the document a bit.

{% post deniselemonaki/don-t-fear-the-command-line-navigation-57od %}

Thanks for this small revision course of command line commands.
The best one I like is the ' rm ' command, which can be used both for moving and renaming files.

Also, I just realised that I cannot empty bin folder with that command.
Keep Coding, keep growing.!


Thank you so much, glad you enjoyed it! :)


Learning the command and being comfortable with it is a super-power. There are things that seem easier and more intuitive with a GUI for most of us. But once you get more comfortable you start to find ways that you can script it, which makes you feel like a wizard. You can also start setting up aliases that do things that you do often with very few keystrokes. At some point, the GUI starts to feel a bit barbaric in comparison.


I never knew about -t, and I've been using Unix on and off for years. very handy, thanks!


Thank you so much, I appreciate that!