find . | grep -c .
- simple way to count number of files and directories below current point, you can add "-type f" to list just files from the find command or "-type d" for just directories
Interestingly there are three ways to see when a box was last rebooted, try all three and see which you prefer:
uptime
- this tells you how long the box has been "up"who -b
- states the date and time the system last started uplast reboot
- lists the date and time of all rebootsI like "who -b" for a quick answer and "last reboot" for more information.
Sometimes you need to know date, time locale and time zone information and thus the following commands can help:$ date
Thu May 11 11:47:03 BST 2017
$ cat /etc/sysconfig/clock
ZONE="Europe/London"
$ locale | grep LANG
LANG=en_US.UTF-8
From the above you can see this machine is in the UK time zone but has a US locale and is also currently in British Summer Time or Daylight Saving for the UK.
I have not tried this myself but socat I believe will act as a proxy, can be loaded with a certificate and thus can display data going to/from a system.
So, Windows files typically end with a Carriage Return, Line Feed or CRLF but Linux/Unix files end with just an LF. Sometimes you end up with a Windows file on Unix and you just need to make it Linux friendly. So, the following will edit the file, so maybe make a backup first!sed -i $'s/\r$//' filename.ext
Some machines may have dos2unix
or d2u
available but sed
is always available.
So, starting with the principle, we should look at Threads, Cores and Sockets, and multiply all three to get the number of CPUs. As is common with Linux there are several ways to get CPU information and you don't need root privilege for all of them either, here are some common and easy options:
lscpu
- display a nice summarylscpu -p
- gives "parsable" output so is easier to use in scriptslscpu | egrep '^Thread|^Core|^Socket|^CPU\('
- extract the numbers for CPU countingnproc --all
- just outputs a number, the CPU countcat /proc/cpuinfo
- full details on each CPUgrep 'processor' /proc/cpuinfo
- extract one line for each processorIt is worth noting that "nproc" is part of coreutils and that egrep is the same as "grep -E" and supports extended regular expressions.
Whilst working with a Linux VM, Ubuntu, running in Hyper-V I ran out of disk space. I could stop the VM and remove all the checkpoints and increase the disk size, however I then needed to get Linux to use this. I wanted to extend the main/primary partition, /dev/sda1
. To do this I first installed GParted -- A free application for graphically managing disk device partitions with the following command:sudo apt install gparted
Then I executed it with sudo gparted
and used the visual interface to increase the partition size and voila!