More useful terminal commands for GNU/Linux

Mike Turcotte-McCusker
Oct 19, 2017
Linux
|
5

In a previous article we talked about some simple commands for people to learn to do in a Linux terminal like changing directories, or copying files.

Today, I’ll be showing you some more useful things the terminal newbie may or may not know how to do, like renaming files, shutting down and rebooting your machine, or scheduling a shutdown/reboot at a specific time.

How to rename files

Simply put, renaming files isn’t done like it is in other systems, we aren’t really renaming the file, we are going to move the file, giving it a new name in the process. To do this, we need to use the command for moving:

  • mv X Y

As discussed in our previous article, mv is the command used to move files from point A to point B. This can be done from within any directory, to any directory, even if you are not currently situated in the director that the file is contained in.

For example

  • sudo mv ~/myfile /var/log/someprogram/logfiles/morefolders/myfile2.log

The above command moves the file ‘myfile’ out of the users home directory and places it into a subfolder of the /var/log directory, under the new name ‘myfile2.log’

Note: The sudo preface was used, because you can’t move a file to /var/ without it, sudo is not essential to using the mv command if you remain out of directories that require root access.

Moving a directory is the same idea:

  • mv ~/test1 ~/Documents/test2

This command will move the directory ‘test1’ into the Documents folder under the new name ‘test2’, and will not change the names or affect the files within that document, keeping them safely intact.

Shutting down and restarting your machine

If you’re using a modern distribution then shutting down and rebooting don’t even need root access (with most distributions) anymore – handy!

Shutdown

Shutting down is as simple as typing:

  • shutdown

To which you will receive a message similar to:

Shutdown scheduled for Thu 2017-09-28 11:49:59 EDT, use 'shutdown -c' to cancel.

And obviously if you wish to cancel:

  • shutdown -c

Rebooting your PC is just as simple:

  • reboot

Done!

However....There are more advanced things we can do with these commands...

  • shutdown -h XX:XX

This command will automatically shut the machine down at the specified time, in 24-hour format. Replace X with the appropriate numbers, and you are done.

  • shutdown -r XX:XX

This will do the same thing, but will reboot the machine at the specified time.

Final words

So there you have a few more neat little tips and tricks for when you’re in a text environment, great for remote servers, or if you’re in a hurry, as I personally find it faster to simply use the various commands, rather than clicking around an interface.

Summary
More useful terminal commands for GNU/Linux
Article Name
More useful terminal commands for GNU/Linux
Description
Mike demonstrates how to rename files, shut down and reboot your machine, or scheduling a shutdown/reboot at a specific time on machines running GNU/Linux.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Previous Post: «
Next Post: «

Comments

  1. Mark Hazard said on October 19, 2017 at 5:43 pm
    Reply

    I haven’t used shutdown for years. I always use the GUI. Command line is so yesterday.

  2. JuliaR said on October 19, 2017 at 1:21 pm
    Reply

    Once I had a beautiful cat which was as long winded as Linux. It died.

    1. goldendays said on October 20, 2017 at 2:00 am
      Reply

      Actually, if one watches a Linux user or a coder working within the “long winded” terminal, their hands float like butterflies and arrive at the desired destination long before “clickers.” One guy I knew could write commands that made little sense to our group–he’d be done and say, “Go and do likewise.” If you only had a chance to watch a “real” terminal man–the terminator of the slow point and click.

  3. Weilan said on October 19, 2017 at 10:01 am
    Reply

    Linux terminal used Bash, correct? I’m not very familiar with it or Linux in general, but I’ve always wondered if one should be very familiar with the language or not, since nowadays even Linux is more UI-oriented and noob-friendly, at least the popular Deb-based distros. And you won’t be required to compile tarballs?

  4. test said on October 19, 2017 at 9:20 am
    Reply

    – to simply rename:

    mv name{A,B}

    (will move ./nameA to ./nameB)

    – to move from/to:

    mv positionA sub/dir/positionB

    (will move ./posiitonA to ./sub/dir/positionB)

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.