Posted: . At: 7:40 AM. This was 7 years ago. Post ID: 9901
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

How to create a dot matrix printer banner with Linux and other useful Linux tricks.

Standard Windows XP error.
Standard Windows XP error.

The printerbanner command will create a dot matrix printer banner. Just run the command and then type a string and hit ENTER.

jason@debian:~$ printerbanner
Message: Debian

Print out the contents of a text file in octal format.

jason@debian:~$ od .dmrc
0000000 042133 071545 072153 070157 005135 060514 063556 060565
0000020 062547 062475 057556 052501 072456 063164 005070 062523
0000040 071563 067551 036556 064554 064147 062164 026555 071570
0000060 071545 064563 067157 000012
0000067

Print out the same file in hexadecimal format.

jason@debian:~$ hd .dmrc
00000000  5b 44 65 73 6b 74 6f 70  5d 0a 4c 61 6e 67 75 61  |[Desktop].Langua|
00000010  67 65 3d 65 6e 5f 41 55  2e 75 74 66 38 0a 53 65  |ge=en_AU.utf8.Se|
00000020  73 73 69 6f 6e 3d 6c 69  67 68 74 64 6d 2d 78 73  |ssion=lightdm-xs|
00000030  65 73 73 69 6f 6e 0a                              |ession.|
00000037

Use the printenv command to print out all environment variables for your current account.

jason@debian:~$ printenv

Print information about an ELF binary file using the readelf command on Debian Stable.

jason@debian:~$ readelf -h /bin/ls
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x4048c5
  Start of program headers:          64 (bytes into file)
  Start of section headers:          116552 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         27
  Section header string table index: 26

The stat command will print information about the filesystem usage of the file.

jason@debian:~$ stat /bin/ls
  File: ‘/bin/ls’
  Size: 118280    	Blocks: 232        IO Block: 4096   regular file
Device: 801h/2049d	Inode: 1572974     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-11-07 22:16:08.692000266 +1100
Modify: 2015-03-15 02:47:04.000000000 +1100
Change: 2016-11-03 18:20:28.331925569 +1100
 Birth: -

To view the partitions on your hard drive, use this command. fdisk -l /dev/sda.

root@debian:/home/jason# fdisk -l /dev/sda
 
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd40953b1
 
Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 60262399 60260352 28.8G 83 Linux
/dev/sda2       60264446 62912511  2648066  1.3G  5 Extended
/dev/sda5       60264448 62912511  2648064  1.3G 82 Linux swap / Solaris
Windows NT4.0 Server. Neanderthal technology.
Windows NT4.0 Server. Neanderthal technology.

This is yet another way to return your IP address of a LAN connected machine.

┌─[jason@darkstar][~]
└──╼ $hostname -I
192.168.100.3

This command will return the external IP address of your Linux machine.

┌─[jason@darkstar][~]
└──╼ $curl http://ipecho.net/plain; echo

These commands will make it very easy to get network IP information quickly. This is how flexible Linux is in regards to combining commands and piping to make sure you only return the information you want from a command.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.