# show battery's statusupower -i /org/freedesktop/UPower/devices/battery_BAT0# time the machine has been runninguptime# file system structure explanationman hier# disk usagedf -k# information about CPUlscpu# display calendarcal# bandwidth usageiftop# network interfaceslspci | egrep -i 'network|ethernet'# info about kernel releaseuname -a# system hardware informationsudo lshwsudo lshw -html > systemInfo.html# shutdown at a specific timesudo shutdown -h 19:05 "Some message..."# stop / start / restart systemctlsudo systemctl start serviceNamesudo systemctl stop serviceNamesudo systemctl restart serviceName# check service statussudo systemctl status serviceName# enable / disable service to run at boot timesudo systemctl enable serviceNamesudo systemctl disable serviceName# increase swap size# 1. Turn off all swap processessudo swapoff -a# 2. Resize the swap to 4GBsudo dd if=/dev/zero of=/swapfile bs=1G count=4# if: input file, of output file, bs: block size# 3. Make the file usable as a swapsudo mkswap /swapfile# 4. Activate the swap filesudo swapon /swapfile
Not long ago, I wrote a post with 25 one-command-liners that allow you to do complex things with just one line without using the graphical interface. Now, I will show you a list of commands to turn you into the perfect Linux mechanic.
Note: All commands have been tested on ubuntu 20.04. To execute some commands, you will need administrator permissions.
System information
Check the battery’s status via the terminal
This command outputs a lot of status and statistical information about the battery.
In my case, I’m using ubuntu on a virtualized machine, so it doesn’t show relevant stats, but if you try it on a native installation, it will show you a lot of helpful information.
Screen with the result displayed on the command line.
Time the machine has been running
The uptime command returns information about how long the system has been running since it was started up the last time.
$ uptime
Screen with the result displayed on the command line.
Show File system structure
The man hier command shows the description of the file system hierarchy.
$ man hier
Screen with the result displayed on the command line.
Display disk usage information
This command shows the disk usage information.
$ df -k
Screen with the result displayed on the command line.
Display information about the CPU
This command shows the CPU usage information.
$ lscpu
Screen with the result displayed on the command line.
Display a calendar with the current day highlighted
This command displays a simple calendar.
$ cal
Screen with the result displayed on the command line.
Display Bandwidth usage
I love this utility; it is handy to know what is happening on your computer and where it is connecting to.
$ apt-get install iftop$ iftop
Screen with the result displayed on the command line.
List network interfaces
This command shows the network interfaces with the “ethernet” name.
$ lspci | egrep -i 'network|ethernet'
Screen with the result displayed on the command line.
Display information about your kernel release
$ uname -a
Screen with the result displayed on the command line.
Display System Hardware information
This command display a lot of information about your Hardware.
$ sudo lshw
Screen with the result displayed on the command line.
If you prefer the short version in HTML format:
$ sudo lshw -html > systemInfo.html
Screen with the result displayed on the browser.
A trick, in the command console, you can display the result in the language of your choice with the following commands:
The primary function of swap space is to substitute disk space for RAM when RAM fills up and more space is needed. With this command, you can set the size of the swap file.
Turn off all swap processes
$ sudo swapoff -a
Resize the swap to 4GB
$ sudo dd if=/dev/zero of=/swapfile bs=1G count=4
if: input file, of output file, bs: block size
Make the file usable as a swap
$ sudo mkswap /swapfile
Activate the swap file
$ sudo swapon /swapfile
Schedule jobs with Crontab Command
Cron is a regular background process manager (daemon) that runs processes at regular intervals (for example, every minute, day, week, or month). The processes to be run and the time they should run is specified in the crontab file.
If you have arrived here, I invite you to look at these other 25 Awesome Linux Command One-Liners, where you will find combinations of Linux commands that I am sure will surprise you.
If you liked this post, please consider subscribing to Medium through myprofile.