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.
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:
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.
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:
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.
If you’re using a modern distribution then shutting down and rebooting don’t even need root access (with most distributions) anymore – handy!
Shutting down is as simple as typing:
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:
Rebooting your PC is just as simple:
However....There are more advanced things we can do with these commands...
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.
This will do the same thing, but will reboot the machine at the specified time.
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.
If you like our content, and would like to help, please consider making a contribution: