How to list all recently logged in users on your Linux system. And other useful Linux tricks.

The sudo lastb command will list all recently logged in users on your Linux system. This is a useful tool on a server. jason@eyjafjallajkull:~$ sudo lastb jason :0 :0 Thu Jan 8 12:41 – 12:41 (00:00) jason :0 :0 Mon Jan 5 11:42 – 11:42 (00:00) jason :0 :0 Mon Jan 5 11:42 – 11:42 […]

A brief look a various network attacks that can compromise your network resources.

A handful of network attacks that can compromise your network nodes TCP attacks   TCP SYN attack: This attack begins as a normal TCP connection, the client and server exchange information in TCP packets. A client sends an ACK packets to the server requesting a connection. The server will respond with a packet acknowledging the […]

How to get the brand and model of your graphics card with the command line.

This command will print out the model and make of your graphics card. This is another command to run on an unknown computer to see what hardware is in it. jason@eyjafjallajkull:~$ lspci -vnn | grep VGA -A 12 | head -n 1 01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Turks XT [Radeon […]

C code that will select a random word from an array and include it in a string.

This code will pick a random word from the x[] array and include it in the printed string. This program will also get your current Linux username to customize the output. I am sure this code would be very useful to someone who wants to know how to handle arrays in C. #include <stdio.h> #include […]

How to format a partition in Linux. This is very easy.

Formatting a partition in Linux is very easy when you use the mkfs command. In this example I am formatting a 35 gigabyte partition with an EXT4 file-system. I am intending to try out a Linux From Scratch build and I want to have a dedicated partition to build this on. jason@eyjafjallajkull:~/Documents$ sudo mkfs.ext4 /dev/sdb2 […]

Linux in Arma 3! A tiling window manager on a laptop in the game.

This is a laptop in Arma 3 that can be placed as an in-game decoration. This is running Linux! Apparently the military dumped Windows after the collapse of Microsoft in 2035. This is a good sign. Linux would be better and more reliable in the field compared to Windows anyway. I wonder what kernel version […]

C code that will open a file and print the contents to the terminal.

This code will print the contents of a file to the terminal. Feel free to use this in your own projects if you wish. #include <stdio.h>   #define MEM "/proc/meminfo"   int main (void) {   FILE *g; char Meminfo[40]; g = fopen(MEM, "r"); if(!g) { printf ("Sorry, I cannot" \ "open: %s.\n", MEM); } […]

How to delete a directory on Linux.

Deleting a directory on Linux is very easy indeed. The rmdir command will perform this task adequately. You could also use the rm -rf abc/ command to delete a directory, but rmdir is easier to remember. eyjafjallajkull% rmdir abc The rmdir command will not be able to delete a directory that is not empty, therefore […]

How to include code inside a loop in C.

This loop I wrote in C enables if statements inside a loop. This could be a useful thing to know. #include <stdio.h>   int main(void) { int k;   for (k = 0; k < 16; k++) { printf("* *\n"); if (k == 4 || k == 12) { printf("\n\t\t-\n"); } if (k == 8) […]

Stealth Linux code that can run on a machine and open a port invisibly.

This code that I found: can run on a Linux machine and open a port invisibly. This allows access to a Linux server without the process showing in process manager and on a port scan of the machine. This might be controversial thing to post on a Linux focused website, but this might be […]

Some useful bash shell scripts for the Linux user.

This function will allow your computer to speak. function shellspeak() { mplayer "$(echo $@ | sed ‘s/\s/+/’)" > /dev/null 2>&1; } A script that will change all files in a directory to lowercase filenames. function lowercase() # move filenames to lowercase. { for file ; do filename=${file##*/} case "$filename" in */*) dirname==${file%/*} ;; *) dirname=.;; […]

How to upgrade a single package if needed using apt.

This command will update a single package upon request. This would be very useful if you want to update only a certain package. dpkg -s <package> 2>/dev/null | grep -q Status.*installed && sudo apt-get install <package> I found this tip here:

Ubuntu 9.10 Human theme for GTK 3.0

This is a good theme for your modern Ubuntu or Linux Mint desktop, a version of the Human theme for GTK 3.0: This is a perfect theme to make your Ubuntu desktop look like the old Ubuntu 8.10 releases. Here is another lovely GTK 3.0 theme, Dorian: A collection of old Ubuntu wallpapers: […]

How to change your hostname on Linux the easy way.

Use the sudo hostnamectl set-hostname HOSTNAME to set a new hostname for your machine. This command does all of the steps in one go and takes the worry out of this task. Just close the terminal after entering this command and reopen it and the new hostname will be visible. Here I am setting a […]

How to shutdown your Linux system properly with the command prompt.

The shutdown command for Linux and UNIX is used to shutdown your Linux system properly. This command will bring down the system immediately. shutdown -h now This will shut down the system in 60 minutes. shutdown -h +60 Use this command to reboot the computer immediately. shutdown -r now Here is an alternative command for […]