This article is about your system time, specifically how to find your timezone in the terminal. It shouldn’t be a very long article and it should be relatively easy and suitable for new Linux users.
Why would you want to find your timezone in the terminal? Well, for starters you may not have the proper time set and need to verify it. You may also be working with servers scattered across the globe and knowing the timezone may be important.
As you may need things synchronized, knowing the timezone could be important. Seeing as you’re not always able to access a GUI desktop, you might want to find your timezone in the terminal. So, to those end, this article will share a few ways to do so.
Find Your Timezone In The Terminal:
Obviously, this article requires an open terminal. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open. If you’re operating remotely, you probably already have a terminal open.
Anyhow, there are multiple ways to do this. For starters, you can just use the date command. It looks like this:
The output will have your timezone in it. For example, the output of that command on one of my boxes looks like:
As you can see, the timezone is at the end. In my case, it’s “EDT” and that’s probably the easiest way to get the timezone information.
You can also use ‘timedatectl’ which looks like this:
That’ll give you the timezone and even tell you the adjustment from GMT. If you want, you can use grep with it.
That will, of course, just output the line containing your timezone. Also, I have no idea why it’s two words. I know it as one word, but here we are and I suppose it’s just not that important.
I have one more way to find your timezone in the terminal and it’ll output your timezone in text. It’s just:
The output from that would look a little like this:
So, there are a few ways. There are surely other ways, so feel free to leave a comment sharing them.
And there you have it, another article. This one shares how to find your timezone in the terminal. It’s a relatively easy article to follow and not really a tool I expect most users to need. Still, it’s there if you need it and this article stands as a reference to it.
Today’s article is about the ‘tail’ command, seeing as the last article was about the ‘head‘ command. The tail command is the head companion’s counterpart. It only makes sense to cover one after covering the other, so today’s article will do just that.
Like the head command, the tail command has been with us for a long time, since pretty much the earliest days of Unix. Where head shows you the first lines in a file, the tail command shows you the lines from the end of the file. The man page describes tail as:
tail – output the last part of files
The tail command is pretty handy, often used by sysadmins to monitor log files. It can also be used like the head command to quickly check the contents of a text file, but it shows the material at the end of the file and not at the start of the file. That’s useful for remembering where you left off, for example. Anyhow, there are all sorts of ways to use it and this article will explain some of them.
Getting Started With The ‘tail’ Command:
I don’t think it’s all that important for this article (I’m not sure, I haven’t written it yet!), but we can start on the same page like we did with the head command.
We’ll need to get started with the terminal open. You can do open your terminal with your keyboard – just press CTRL + ALT + T and your default terminal should open.
Once you get the terminal open, you can run the following two commands. Be sure to press the enter button after each of them and it will download a handy text file (just some random numbers) so that we’re all working on the same file.
With that complete, we can head on into the main article! It shouldn’t be all that long or difficult.
The ‘tail’ command:
Seeing as you’ve already got the rnd-num.txt file downloaded and your terminal is already open, I think we can just jump into using the tail command. If you just want to view last 10 lines of a file, you can use this command:
On the other hand, you can use the -n flag to show a specific number of lines. If you only wanted to see the bottom 5 lines, you’d use this command:
Assuming you’re all playing the home game, and just to show a good example, the output from the final command would look similar to this:
Along the same lines, but not necessarily as useful, is the -c command. It works the same way it does in the head command, namely showing the specified number of bytes. If you wanted to see the final 5 bytes, the command would look like:
You can also use tail on more than one file at a time. If you do so, you can also use the -v flag and it will helpfully show the names of the files. The command would look a little like this:
The output would look similar to this:
One of the command options available with tail isn’t available with head. That flag is the -f mostly used for logs. What happens is you use the -f flag and then tail keeps running, outputting new lines to your terminal as the occur. In that case, it’d be something like:
That should show the last 10 lines of the log file and then update when new lines are added to the log file you’ve opened. Use man tail for more usage information.
And that’s it! There’s another article for the site and another article closer to reaching the project’s goals. This article covers the tail command, seeing as the head command was covered in the last article. Feel free to leave a comment sharing how you use the tail command, or maybe even just a comment or question to motivate me.
Today’s article is about the ‘head’ command. The head command is a tool for viewing a file’s contents (or piped data), starting from the top. There’s not a whole lot to the command, and this will make be a pretty short article that’s fit for a beginner.
The head command has been with us since the heady days of Unix (See what I did there?) and is still a useful command today. In fact, the man page defines it like this:
head – output the first part of files
As you can guess, it does exactly what it says on the tin. There are any number of circumstances when you might want to use it, but I often use it when I don’t remember the exact filename I’m after and just want to see the first few lines of text as a reminder. There are better uses.
Anyhow, there’s not a whole lot to it, but I’ll show you the basics. Like we did recently, let’s see if we can all get started on the same page. So, open your terminal and enter the following:
Doing that will put you in the Downloads directory and will download a text file (it’s perfectly harmless) and it means we are all working with the same settings. You do not need to do this, but it could help.
About The ‘head’ Command:
Seeing as you’ve already got the terminal open, and that you figured it out without me having to repeat it like I do in almost every article, we’ll just jump right into the first command.
That should output the first ten lines of the rnd-num.txt file, looking something like this:
That’s the first ten lines from the rnd-num.txt file or, in other words, the head of the file has been outputted to the terminal. This has a number of uses, including the pipe. You can easily pipe it to another command. It’d look something like this:
That’s not all that head can do, it can output a specified number of lines. To do that, you use the -n flag. It looks like this:
You can also use the -c flag to show the first x-number of bytes in a file. That’s not very complicated. In this case, we’ll look at the first 25 bytes.
You’ll find the output looks pretty similar to the output from the previous head command. You can even work with multiple files and the head command will handle them easily. If you’re going to use multiple files, you should use the -v flag.
It’ll helpfully preface the start of each file with the name of the file. In this case, the first line of the output would look like this:
See? Pretty helpful!
As shown in the image, you can easily deal with multiple files and whatnot, but there’s really not much more to be done with the head command. If you’re curious, you can also enter man head to get more usage information.
Yup… There’s another article. This is about the head command, a command that’s not used often but worth having in your toolbox. If you use it more often, feel free to leave a comment explaining what you do with it.
Many Windows users will want to clear cache, buffer, and swap space. It’s a holdover from their Windows days, and it’s possible to do those things with Linux. This article will explain how to clear your RAM cache, buffer, and swap space.
One of the first questions we should be asking is, “Will this help?” The answer is, like many things, “Well, it depends…” It depends on a number of variables, like how much RAM you have, and how aggressively the kernel is paging, or what your swap preferences are. For example, quite a few people have decided to forgo swap entirely. Cleaning swap space is not going to help them out one bit.
The second question should be, “What exactly are we cleaning, anyhow?” The answer to that is a bit clearer, thankfully. The things we’ll be dealing with are:
PageCache/Page Cache; The Linux kernel stores data in unused sections of memory in case it needs it again. Since kernel 2.2, Buffer Cache and Page Cache have been combined and there’s just PageCache.
Dentries; They’re “the in-memory representation of a directory entry” and include things like meta data.
Inodes; Meta data about all the files on your mounted file systems.
Those things build up in RAM and they can be cleaned out. The Linux kernel is really good at managing these things and unused RAM is wasted RAM (within reasonable limitations), but they can be cleaned out and this article explains how.
Clear Cache, Buffer, And Swap Space:
This article requires an open terminal. To open one, you can just use your keyboard – press CTRL + ALT + T and your default terminal should open right up!
I took the time to explain what you’ll be cleaning in the article’s opening. That’ll make this section easier!
To clear PageCache by itself:
sudo sh-c'echo 1 > /proc/sys/vm/drop_caches'
Or you can clear Dentries and Inodes:
sudo sh-c'echo 2 > /proc/sys/vm/drop_caches'
Or even clear PageCache, Dentries, and Inodes at once:
sudo sh-c'echo 3 > /proc/sys/vm/drop_caches'
NOTE: These work as advertised. Before you run one of these commands, run free -m before and after running the command. By doing that, you can see what the results are and what the results will probably look like in the future.
Frankly, I’d only see this as a very valuable tool if you have little RAM, or want to free up some resources before opening something that is resource-intensive. Other than that, just let Linux do its job – managing cache, memory, and other resources.
But, if you’re a Windows user and want the comfort of some familiarity, this won’t harm anything and could provide the very slightest of benefit. You could even alias it to an easier-to-type command and run it as often as you want. It’s your computer, you do what you want with it!
There it is, another article! We’re rapidly approaching the 6 month mark and so far things have gone well. This time, you get an article letting you know how to clear cache, buffer, and swap. Who knows what the next article will be?
This is a guest article by @captain-sensible, about Linux installation – specifically creating USB media using Windows. I trust him on this, and don’t feel qualified to do much in the way of editing as I know next to nothing about Windows. So, without further ado:
If you already have Linux as your OS, then an article about how to get a Linux .iso onto a USB stick is probably redundant. The other thing I can deduce is that if you want to have a go at trying to install Linux, that would mean you probably don’t have Linux OS nor access to programs that run on Linux.
You might think an article involving Windows is not a good fit for Linux tips? Well I disagree the tip to put it succinctly is this – “Linux and how to get it” I.e. you want Linux but you don’t have it, and so the article is about getting it using the only tool you probably have at your disposal, which is Windows. (That’s assuming you don’t have any avisée friends using Linux)
Therefore, I am going to go through how to use Windows and software tools to get a Linux OS iso file onto a USB from which you can boot. Maybe in part 2 I could mention use of ventoy on a Linux box and persistence for a live Linux OS on a usb .
Now there are a couple of tools you can try including:
But here we will have a look at Ventoy. Ventoy has a couple of useful features – you can put several Linux ISOs onto the same stick and boot from any of them via the Ventoy boot splash menu. Also via one of the Ventoy tools called CreatePersistentImg a file is created, inside the same directory that the script is run and can be configured to be used on the formatted stick with the ISOs so that the live OS can install software.
Our Agenda will be:
Download a Linux .iso file
use Ventoy to format a USB stick we have
Drag .iso file onto ventoy formated stick
Boot from USB stick
Create USB Media Using Windows:
Normally I use Linux with ventoy; for this exercise using Windows10, I downloaded linuxmint-20.2-cinnamon-64bit.iso from University of Kent Mirror.
Shimmy down to ventoy-1.0.52-windows.zip and mouse left click to download it to your PC. Right click and choose “extract”. You will probably get something like select a destination – go for Desktop if you can; at least you can find it easily.
Anyway that will unzip the zip file. I found once unzipped that the directory I wanted was inside another directory called ventoy-1.0.52-windows, the directory and its contents you want is the one labelled ventoy-1.0.52.
See image below:
That’s the one that contains the tools you need including Ventoy2Disk, an executable Windows file. Drag that directory from inside the outer directory to your desktop.
To fire up Ventoy, go inside the ventoy-1.0.52 directory and mouse left click twice on Ventoy2Disk. You should then see a dialogue box (see image below). Now from the image it tells you that it thinks Device E: SanDisk is the USB stick to be formatted. The main point being you need to insert a preferably virgin USB stick, a USB thumbdrive with nothing on it, into your PC before Ventoy2Disk can work on anything.
Now its always best to double check things. One way of doing that is to fire up a disk utility and see what’s listed. You will use common sense as well – A 16GB storage device is unlikely to be your PC internal hard drive. Lets have a look anyway.
One way of confirming is to use Disk management. To fire that up hit the key with Windows Icon on it and R, that should bring a dialogue box up with a text box . Into the text box type Diskmgmt.msc; you should then see Disk Management and entries – see image left.
I think I can conclude with Ventoy that Spare E is the USB I want to use. One reason is that I formatted it and labelled it using GParted. So next with USB attached to PC, left click on the install button of the Ventoy dialogue box. Now when its finished, pull the USB out and re-insert it , that’s to make sure the PC is correctly recognizing, the USB which will now have a label – ventoy.
If you look at the above image, a window is open with location of the ISO file and the other Window on the right is the newly labelled USB stick called ventoy opened. All you have to do is use your mouse and literally drag holding down left, on the mouse from the left window onto the right window. You might have to fiddle with Windows, I know I did with Windows 10 on the laptop I was using.
Once that’s been done its a case of now shutting down Windows and from a cold boot hit the key which will give you boot options. The laptop I was doing the operation was a H.P stream so for that laptop F9 is the boot option key and F10 is the bios. You have to hit the keys almost immediately after powering up.
I had a couple of glitches on powering up, getting the boot option and booting from the USB I got “image not authenticated “now what came to mind was checking the integrity of the download. No that wasn’t it.
One issue was expected in disabling secure boot and enabling legacy boot; the other one wasn’t. What is was is that although I had edited the BIOS, there was a “Operating System Boot Mode Change” notification.
I did as requested entered the number quoted, hit Enter (return key) and after that I was Ok. I then got Mint booted live! Finally – Windows doesn’t like to let go easily.
Now when you get to the stage of getting a Linux OS up live from a USB here are a view bits of advice:
On the Desktop of your live Linux OS you will see an icon saying install Linux, don’t rush in and do that. Play around for a week with the live OS, get to know it and try of launching a shell (terminal window). Learn to use, at least launch and have a look at tools such as GParted and screenshot. You can use apt-get or apt from a terminal to search for that.
Those sort of tools and your ability to use them will come in extremely handy if you have any issues and need help from a Linux forum. Users will want to see your partitions (use gParted) and see what some things look like (use screenshot) they will probably also want to see some output of commands on the shell (your ability to use basic commands needed).
The live Linux OS you have doesn’t have persistence, you can play with installing software and it should install but only in RAM. You can achieve persistence with the Ventoy approach, but thats perhaps for another time.
There you have it, an article about creating Linux installation USB media using Windows. This one was written by a guest, now a registered user and author. So, kudos to them for stepping up and contributing!