Showing posts with label OpenBSD. Show all posts
Showing posts with label OpenBSD. Show all posts

Monday, April 28, 2025

Version of UNIX/BSD I am using - uname tutorial

To find out which version of OS we are using, we will use UNIX uname command, alone, or with additional options:

This is result on my system:

#uname
OpenBSD

More info about system you will get with "uname -a":

#uname -a OpenBSD swordfish 4.8 GENERIC#136 i386

Machine type,  "uname -m":

#uname -m i386

Machine nodename (network name),  "uname -n":

#uname -n swordfish

Some details on processor, "uname -p":

#uname -p Intel(R) Pentium(R) 4 Mobile CPU 1.70 GHz ("GenuineIntel" 686-class)

Release with "uname -r":

#uname -r 4.8

System version, "uname -v":

#uname -v GENERIC#136

All in all, except "uname -p" for info on CPU, all you need is "uname -a".

Check your man uname page.

Software Installed on OpenBSD System , pkg-info tutorial

To find out what we have on our OpenBSD system, we will use pkg_info:

#pkg_info

BitTorrent-4.4.0p6  cooperative file distribution system implemented in Python
BitTorrent-gui-4.4.0p6 graphical interface components for BitTorrent
ImageMagick-6.4.5.6p0 image processing tools
ORBit2-2.14.18      high-performance CORBA Object Request Broker
OpenEXR-1.6.1p1     high dynamic range image format
agg-2.5p1           anti-grain geometry graphics library
amarok-1.4.10p4     music player for KDE
arts-1.5.10p3       K Desktop Environment, aRTs
aspell-0.60.6p4     spell checker designed to eventually replace Ispell
atk-1.30.0p0        accessibility toolkit used by gtk+
august-0.63bp0      html editor designed for the experienced web designer
avahi-0.6.27        framework for Multicast DNS Service Discovery
blas-1.0p3          Basic Linear Algebra Subprograms
boost-1.42.0p2      free peer-reviewed portable C++ source libraries
bzip2-1.0.5         block-sorting file compressor, unencumbered
cairo-1.8.10p0      vector graphics library
cdparanoia-3.a9.8p0 CDDA reading utility with extra data verification features
curl-7.20.0         get files from FTP, Gopher, HTTP or HTTPS servers
cyrus-sasl-2.1.23p0 RFC 2222 SASL (Simple Authentication and Security Layer)
dbus-1.2.24p4       message bus system
dbus-glib-0.86p1v0  glib bindings for dbus message system
desktop-file-utils-0.16p0 utilities for 'desktop' entries
epdfview-0.1.7p5    lightweight PDF document viewer
faac-1.26           MPEG-2 and MPEG-4 AAC encoder
faad-2.6.1p1        MPEG-2 and MPEG-4 AAC decoder
ffmpeg-20100512p0   audio/video converter and streamer with bktr(4) support
flac-1.2.1p0        free lossless audio codec
fribidi-0.10.4p0    library implementing the Unicode Bidirectional Algorithm
gconf2-2.28.1p2     configuration database system for GNOME
gdbm-1.8.3p0        GNU dbm
gettext-0.18.1      GNU gettext
ghostscript-8.63p13 GNU PostScript interpreter
ghostscript-fonts-8.11p2 35 standard PostScript fonts with Adobe name aliases
glib2-2.24.1p2      general-purpose utility library
glitz-0.5.6p2       OpenGL image compositing library
gnash-0.8.3p4       flash player with firefox browser plugin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
 Cut here because of readability
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
x264-20100511       free H264/AVC encoder
xine-lib-1.1.18.1p1 multimedia decoding library
xvidcore-1.2.2p1    ISO MPEG-4 compliant video codec
yt-15               fetch youtube and google videos 

You can use some options with pkg_info, example for package  yt-15:

#pkg_info -c yt-15,  for comment about program/package at one line

Information for inst:yt-15

Comment:
fetch youtube and google videos

#pkg_info -d yt-15,  for detailed comments on installed program/package

 Information for inst:yt-15

Description:
yt is an extensible Lua script to fetch videos from YouTube.com. You can
(and probably should) customize it to use your preferred encoding tool.
By default it uses graphics/ffmpeg.

Maintainer: Martynas Venckus <martynas@openbsd.org>

OpenBSD pkg_info do have some more options, and it is used on other BSD system, so you need to check man pkg_info page for your OS version.

In any case, it is important to know (if you get your hands on OpenBSD) that report on installed software is available with pkg_info.

Multiple IP Addresses on Single Network Card - OpenBSD IP Alias tutorial

Situation: 

1. Do you have a router (a separate device) through which several computers in a company goes to the Internet (via a hub). In this case that is a wireless router.  
2. Router must have a static IP address (eg 192.168.1.1), so that in the event of a server crash some of the clients on the LAN at the company could fix him. 
3. Some computers on the LAN do not need to have a static local address, but some do. 
4. ISP assigns you a dynamic IP address for the router and computers behind them, if you set them so.
5. Some of computer on LAN need to have, for various reasons, bouth static and dynamic IP. Of course, server is among them.

Why OpenBSD server need to have a dynamic address? 

Because in this case server must have indipendent connection to outside world. 

You should not be dependent (in office) on just one line to the Internet - must be able for fast switch to another Internet line, with second router, dial up modem or  other device (radio, satelite link, etc). 

Why server must have a static IP address, other than those provided by the dynamic ISP via DHCP? 

To access computer in the local network and reverse, regardless of whether it has or does not have access to the internet. 

Why does the router to your ISP has a static IP address?
 
 In case of cancellation of the server, which has a static IP address (alias) and dynamic address given by the ISP, computers that are behind a router on the local network (typically workstations) can access the router and configure router if needed.

 If router loses a dynamic address, computers that were behind him will also lose their IP adresses. In order to set up the router, it must be reset to factory setings. 

And that can be done just with static adressing. 

So, we don't wan't to waste company time, right ?

Note, it is possible for you to have multiple accounts with one (wireless) ISP over just one router. It is important to note that the OpenBSD machines do have just one network card, in this case, and no more. But we need multiple IPs for our OpenBSD server.

 How to set up one or more IP addresses on one card ?:

 ifconfig fxp0 alias 192.168.1.49 255 255 255 255

Explanation:

ifconfig - this command adjusts the network parameters of the OpenBSD and similar systems
fxp0 - this is the network card on the system
192.168.1.49 - this is the IP address that we want to add 255 255 255 255 - this is the "netmask". Use this IP address when you make IP alias, after "real" IP (192.168.1.49)

For example, let's add one more IP address to NIC:

ifconfig fxp0 alias 192.168.1.23 255.255.255.255
# Ifconfig fxp0
fxp0: flags = 8843 mtu 1500
        lladdr 00:00: xx: xx: xx: xx
        priority: 0
        media AutoSelect Ethernet (100BaseTX full-duplex)
        Status: Active
        inet6 xxx% fxp0 prefixlen 64 scopeid 0x1
        iNet 10x.x01.111.16 netmask 0xffffff00 broadcast 10x.x01.111.255
        inet 192.168.1.49 netmask 0xffffff00 broadcast 255,255,255,255
        inet 192.168.1.23 netmask 0xffffff00 broadcast 255,255,255,255

Can we ping router now ?

# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=0.751 ms
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.970 ms
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.751/0.860/0.970/0.113 ms
#

As soon as we can ping something, we can manage that thing, right ?
Do we have an exit to the Internet?

# ping google.com
PING google.com (173.194.39.69): 56 data bytes
64 bytes from 173.194.39.69: icmp_seq=1 ttl=52 time=38.831 ms
64 bytes from 173.194.39.69: icmp_seq=2 ttl=52 time=23.956 ms
64 bytes from 173.194.39.69: icmp_seq=3 ttl=52 time=10.524 ms
64 bytes from 173.194.39.69: icmp_seq=4 ttl=52 time=12.198 ms
--- google.com ping statistics ---
5 packets transmitted, 4 packets received, 20.0% packet loss
round-trip min/avg/max/std-dev = 10.524/21.377/38.831/11.328 ms
#

Ok, the system is up.

If you want to assign a permanent IP alias to a network card ?

It is necessary to add this line to  /etc/hostname.fxp0 :

inet alias xxx.xxx.xxx.xxx 255.255.255.0

Of course, instead of Xs insert the desired IP address you need.

To delete an alias IP's use the command

# Ifconfig fxp0 delete 192.168.1.23 
# Ifconfig fxp0 delete 192.168.1.49

Now you can have a lot of "NICs" at your disposal.

How to take screenshot - OpenBSD - Scroot

We can take a screenshot in UNIX/BSD/Linux systems with "scrot" program.

First, I will install it on my OpenBSD system. Let's define location where packages are, with PKG_PATH:

# export PKG_PATH=http://ftp.vim.org/OpenBSD/4.8/packages/i386 
Checking program description and location with "pkg_info scrot": 
# pkg_info scrot    
Information for http://ftp.vim.org/OpenBSD/4.8/packages/i386/scrot-0.8p1.tgz

Comment:
commandline screen capture util

Description:
scrot is a commandline screen capture util like "import", but using
imlib2. It has lots of options for autogenerating filenames, and can
do fun stuff like taking screenshots of multiple displays and glueing
them together.

Maintainer: Victor Sahlstedt 

WWW: http://www.linuxbrit.co.uk/scrot/ 
Ok. Now we will instal scrot with pkg_add: 
# pkg_add -v scrot-0.8p1.tgz

scrot-0.8p1:imlib2-1.4.2p1: ok                                                 
scrot-0.8p1:giblib-1.2.4p4: ok                                                 
scrot-0.8p1: ok                                                                
# 

That's fine. Please note that saved shots will be in working directory. In this case "/home/scrot":

#pwd
/home 
# mkdir scrot
# cd scrot
# pwd
/home/scrot

So far, so good. Take note about naming convention : 

# man scrot man: Formatting manual page...

scrot(1)                                                 scrot(1)

NAME
       scrot - Screen capture using imlib2

SYNOPSIS
       scrot [options] [file]

DESCRIPTION
       scrot  is  a  screen capture utility using the imlib2 library to aquire
       and save images.  scrot has a  few  options,  detailed  below.  Specify
       [file]  as  the  filename  to save the screenshot to.  If [file] is not
       specified, a date-stamped file will be dropped in  the  current  direc-
       tory.

Last check, are we in right directory ?

# pwd
/home/scrot
# ls
# 

To get a screenshot of whole screen, we need just "scrot", without additional options. Default filetype is .png. Take note about timestamp.

# scrot
# ls
2013-01-04-152547_1024x768_scrot.png
# 

If we need countdown option:  

# scrot -d 5 -c 

Taking shot in 5.. 4.. 3.. 2.. 1.. 0.
# ls
2013-01-04-152547_1024x768_scrot.png    2013-01-04-152940_1024x768_scrot.png
#    

In case above, "-d" is for countdown, "5" is number of seconds, and "-c" is for showing countdown on screen.

You can define quality of screenshot in range scale up to 100. Default quality is 75. We will use "scrot -q 10", just to test it:

# scrot -q 10 
# ls -lh 

total 548
-rw-r--r--  1 root  wheel  94.2K Jan  4 15:25 2013-01-04-152547_1024x768_scrot.png
-rw-r--r--  1 root  wheel  95.5K Jan  4 15:29 2013-01-04-152940_1024x768_scrot.png
-rw-r--r--  1 root  wheel  81.1K Jan  4 15:32 2013-01-04-153221_1024x768_scrot.png
# 

Pay attention to size of shot on 153221, it's smaller than 152940, of course.

How to change file type for screenshot ? For example, use "$t filename.jpg" :

# scrot $t desktop.jpg
# ls -lh
total 792
-rw-r--r--  1 root  wheel  94.2K Jan  4 15:25 2013-01-04-152547_1024x768_scrot.png
-rw-r--r--  1 root  wheel  95.5K Jan  4 15:29 2013-01-04-152940_1024x768_scrot.png
-rw-r--r--  1 root  wheel  81.1K Jan  4 15:32 2013-01-04-153221_1024x768_scrot.png
-rw-r--r--  1 root  wheel   120K Jan  4 15:38 desktop.jpg

Now we have screenshot in .jpg format.

How to take screenshot of window, or region ?

Use "scrot -s" command, pres ENTER, left mouse clickdefine region, release click, wait for prompt:

# scrot -s $t windows.jpg  
# ls -hl
total 876
-rw-r--r--  1 root  wheel  94.2K Jan  4 15:25 2013-01-04-152547_1024x768_scrot.png
-rw-r--r--  1 root  wheel  95.5K Jan  4 15:29 2013-01-04-152940_1024x768_scrot.png
-rw-r--r--  1 root  wheel  81.1K Jan  4 15:32 2013-01-04-153221_1024x768_scrot.png
-rw-r--r--  1 root  wheel   120K Jan  4 15:38 desktop.jpg
-rw-r--r--  1 root  wheel  41.8K Jan  4 15:42 windows.jpg 

New file is windows.jpg, and that file is smaller, because region for shot is smaller than whole screen.

Scrot program have option to define shot width, height, to execute additional command after taking shot (copy to another dir), etc.

Check man page for your version of scrot.

How to Mount Android phone as Flash Drive in OpenBSD

If you need to transfer some files to OpenBSD box from cell phone/flash/card.

But before everything:

Please, be sure that your mem.card/flash/external disk is properly pluged in USB/sock/whatever.

First I will make "htc" directory in /mnt:

#pwd
/mnt
#mkdir htc

Is directory there ?

#ls
htc

Ok. Let plug device into USB port. Here is report from console:

umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2targets, inititor 0
sd0 at scsibus1 targ 1 lun0: <HTC, Android Phone, 0100> SCSI2 0/direct removable
sd0: drive offline

So far, so good. Now, run disklabel sd0:

#disklabel sd0

# /dev/rsd0c:
type: SCSI
disk: SCSI disk
label: Android Phone   
uid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 240
total sectors: 3862528
boundstart: 0
boundend: 3862528
drivedata: 0 

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  c:          3862528                0  unused                   
  i:          3862399              129   MSDOS                   

What we have ? fstype is MSDOS :) , and sd0 goes sd0i ( i = partition, see above).

Mounting:

#mount -t msdos /dev/sd0i /mnt/htc

Check:

#mount:

/dev/wd0a on / type ffs (local)
/dev/wd0k on /home type ffs (local, nodev, nosuid)
/dev/wd0d on /tmp type ffs (local, nodev, nosuid)
/dev/wd0f on /usr type ffs (local, nodev)
/dev/wd0g on /usr/X11R6 type ffs (local, nodev)
/dev/wd0h on /usr/local type ffs (local, nodev)
/dev/wd0j on /usr/obj type ffs (local, nodev, nosuid)
/dev/wd0i on /usr/src type ffs (local, nodev, nosuid)
/dev/wd0e on /var type ffs (local, nodev, nosuid)
/dev/sd0i on /mnt/htc type msdos (local)

That's it.  Now, do what you need to do with your data in /mnt/htc or some other dir...

For sure, check your local man mount/umount page.

How to make files from a list in Perl

Some time ago I was in need to create a lot of html files, thousands of them in some 20 dirs. So, no manual work here, of course.

Here is simple Perl script to automate this process. There is some file, list-to-make.txt, in this case, where on every line you have name of future file. Program will read that list, and for every line make empty file using system touch UNIX command.

Please note, if you need file with some extension, than state that extension in list-to-make.txt, example:

  • 1file
  • 2file.txt
  • 3file.html
  • 4file.htm

Source code in Perl:

#!usr/bin/perl

print "****************************************************************\n";
print "Program: massmake.pl, ver:0.1, 11/Dec/2012\n";
print "Autor : Milan Smudja";
print "****************************************************************\n";
#This program will make files listed in list-to-make.txt in same dir 
#where program is stored. 

open SOURCEFILE, "list-to-make.txt" || die "Damn, can\'t read from file$!";
@lines = <SOURCEFILE>;
foreach $line (@lines) {
   system "touch $line" || die "Can\'t use sustem touch... $!";
}

 

List files in UNIX directory - ls command

UNIX ls command is something you will need every day if you decide to move to or work on UNIX systems. UNIX ls command is used for listing files and directories on all operating systems similar to UNIX.

Depending on the directory where you are, you will get a list of files and directories, in order to check your parent dir, use UNIX pwd command.

UNIX ls command has many options, for example, if you type just ls, you will get a simple report.

If you type ls -1 (number one), you have a report format "line by line". The command ls-A produce report without the "." and "..", while the command ls -a produce report with "."

You need the directories? - You will use ls-F and at the end of each directory there will be slash ("/"), asterisk ("*") for an executable file ("@") sign to the symbolic link (or "=") for the socket.

UNIX ls command with the -g, gives a detailed report on current directory without the information about the owner:

#ls -g

total 47376
-rw-r--r--   1 wheel      578 Aug 16  2010 .cshrc
-rw-r--r--   1 wheel      411 Aug 16  2010 .profile
drwxr-xr-x   2 wheel      512 Aug 16  2010 altroot
drwxr-xr-x   2 wheel     1024 Aug 16  2010 bin
-rw-r--r--   1 wheel    47320 Sep  7  2011 boot
-rw-r--r--   1 wheel  8854601 Sep  7  2011 bsd
-rw-r--r--   1 wheel  8878433 Sep  7  2011 bsd.mp
-rw-r--r--   1 wheel  6327987 Sep  7  2011 bsd.rd
drwxr-xr-x   3 wheel    23552 Dec 21 05:15 dev
drwxr-xr-x  33 wheel     2560 Dec 21 05:21 etc
drwxr-xr-x  14 wheel    22016 Dec 21 06:34 home
drwxr-xr-x   6 wheel      512 Sep 26  2011 mnt
drwx------  20 wheel     1536 Dec 21 05:16 root
drwxr-xr-x   2 wheel     1536 Aug 16  2010 sbin
drwxr-xr-x   2 wheel      512 Aug 16  2010 stand
lrwxr-xr-x   1 wheel       11 Sep  7  2011 sys -> usr/src/sys
drwxrwxrwt   5 wheel      512 Dec 21 06:32 tmp
drwxr-xr-x  17 wheel      512 Aug  8  2010 usr
drwxr-xr-x  25 wheel      512 Sep 14  2011 var

Most useful combination? For shure that is  ls -l. This combination is similar to ls -g, but you will get report with owner info:

#ls -l

total 47376
-rw-r--r--   1 root  wheel      578 Aug 16  2010 .cshrc
-rw-r--r--   1 root  wheel      411 Aug 16  2010 .profile
drwxr-xr-x   2 root  wheel      512 Aug 16  2010 altroot
drwxr-xr-x   2 root  wheel     1024 Aug 16  2010 bin
-rw-r--r--   1 root  wheel    47320 Sep  7  2011 boot
-rw-r--r--   1 root  wheel  8854601 Sep  7  2011 bsd
-rw-r--r--   1 root  wheel  8878433 Sep  7  2011 bsd.mp
-rw-r--r--   1 root  wheel  6327987 Sep  7  2011 bsd.rd
drwxr-xr-x   3 root  wheel    23552 Dec 21 05:15 dev
drwxr-xr-x  33 root  wheel     2560 Dec 21 05:21 etc
drwxr-xr-x  14 root  wheel    22016 Dec 21 06:34 home
drwxr-xr-x   6 root  wheel      512 Sep 26  2011 mnt
drwx------  20 root  wheel     1536 Dec 21 05:16 root
drwxr-xr-x   2 root  wheel     1536 Aug 16  2010 sbin
drwxr-xr-x   2 root  wheel      512 Aug 16  2010 stand
lrwxr-xr-x   1 root  wheel       11 Sep  7  2011 sys -> usr/src/sys
drwxrwxrwt   5 root  wheel      512 Dec 21 06:32 tmp
drwxr-xr-x  17 root  wheel      512 Aug  8  2010 usr
drwxr-xr-x  25 root  wheel      512 Sep 14  2011 var

If you need info on last change you will use ls - lt:

#ls -lt

total 47376
drwxr-xr-x  14 root  wheel    22016 Dec 21 06:34 home
drwxrwxrwt   5 root  wheel      512 Dec 21 06:32 tmp
drwxr-xr-x  33 root  wheel     2560 Dec 21 05:21 etc
drwx------  20 root  wheel     1536 Dec 21 05:16 root
drwxr-xr-x   3 root  wheel    23552 Dec 21 05:15 dev
drwxr-xr-x   6 root  wheel      512 Sep 26  2011 mnt
drwxr-xr-x  25 root  wheel      512 Sep 14  2011 var
-rw-r--r--   1 root  wheel    47320 Sep  7  2011 boot
lrwxr-xr-x   1 root  wheel       11 Sep  7  2011 sys -> usr/src/sys
-rw-r--r--   1 root  wheel  8878433 Sep  7  2011 bsd.mp
-rw-r--r--   1 root  wheel  6327987 Sep  7  2011 bsd.rd
-rw-r--r--   1 root  wheel  8854601 Sep  7  2011 bsd
drwxr-xr-x   2 root  wheel     1536 Aug 16  2010 sbin
drwxr-xr-x   2 root  wheel     1024 Aug 16  2010 bin
-rw-r--r--   1 root  wheel      578 Aug 16  2010 .cshrc
-rw-r--r--   1 root  wheel      411 Aug 16  2010 .profile
drwxr-xr-x   2 root  wheel      512 Aug 16  2010 altroot
drwxr-xr-x   2 root  wheel      512 Aug 16  2010 stand
drwxr-xr-x  17 root  wheel      512 Aug  8  2010 usr

Last access time is available with  ls -lu:

#ls -lu

total 47376
-rw-r--r--   1 root  wheel      578 Jan 29  2012 .cshrc
-rw-r--r--   1 root  wheel      411 Jan 29  2012 .profile
drwxr-xr-x   2 root  wheel      512 Dec 21 07:09 altroot
drwxr-xr-x   2 root  wheel     1024 Dec 21 07:20 bin
-rw-r--r--   1 root  wheel    47320 Jan 29  2012 boot
-rw-r--r--   1 root  wheel  8854601 Jan 29  2012 bsd
-rw-r--r--   1 root  wheel  8878433 Jan 29  2012 bsd.mp
-rw-r--r--   1 root  wheel  6327987 Jan 29  2012 bsd.rd
drwxr-xr-x   3 root  wheel    23552 Dec 21 07:17 dev
drwxr-xr-x  33 root  wheel     2560 Dec 21 07:09 etc
drwxr-xr-x  14 root  wheel    22016 Dec 21 07:09 home
drwxr-xr-x   6 root  wheel      512 Dec 21 07:17 mnt
drwx------  20 root  wheel     1536 Dec 21 07:13 root
drwxr-xr-x   2 root  wheel     1536 Dec 21 07:17 sbin
drwxr-xr-x   2 root  wheel      512 Dec 21 07:10 stand
lrwxr-xr-x   1 root  wheel       11 Sep  7  2011 sys -> usr/src/sys
drwxrwxrwt   5 root  wheel      512 Dec 21 07:18 tmp
drwxr-xr-x  17 root  wheel      512 Dec 21 07:16 usr
drwxr-xr-x  25 root  wheel      512 Dec 21 07:07 var 

Always check your man ls page.

Check who is logged into UNIX server

The answer to the question: "Who is logged on to the system?" is simple. Just use UNIX "who" command:

# who   
root     ttyC0    Dec 30 13:45 
root     ttyp1    Dec 30 14:43   (:0.0)
root     ttyp3    Dec 30 13:47   (:0.0)
root     ttyp4    Dec 30 14:00   (:0.0)
root     ttyp6    Dec 30 14:02   (:0.0)
root     ttypc    Dec 30 14:35   (:0.0)

If this report is not clear, use the "who" command with the addition of -H, to get report Header:

# who -H
USER     LINE     WHEN           FROM 
root     ttyC0    Dec 30 13:45 
root     ttyp1    Dec 30 14:43   (:0.0)
root     ttyp3    Dec 30 13:47   (:0.0)
root     ttyp4    Dec 30 14:00   (:0.0)
root     ttyp6    Dec 30 14:02   (:0.0)
root     ttypc    Dec 30 14:35   (:0.0)

Well, this report is not so interesting at all. Just me. It's ok, there is no any of paratroopers:

With "who -m", or "who am i" or "who i am" you can get info on current terminal:

# who -m 
root     ttyp1    Dec 30 14:43   (:0.0)
# who i am
root     ttyp1    Dec 30 14:43   (:0.0)
# who am i
root     ttyp1    Dec 30 14:43   (:0.0)
# 

Fast report is available with "who -q":

# who -q 
root     root     root     root     root     root     
# users=6
# 

You can get terminal status with "who -T". There is 3 options, writable (+), not writable (-), i some problem (?):

# who -T
root     - ttyC0    Dec 30 13:45 
root     + ttyp1    Dec 30 14:43   (:0.0)
root     + ttyp3    Dec 30 13:47   (:0.0)
root     + ttyp4    Dec 30 14:00   (:0.0)
root     + ttyp6    Dec 30 14:02   (:0.0)
root     + ttypc    Dec 30 14:35   (:0.0) 

Do you want to kick somesone from system ?  No problem, just check idle time with "who -u":

# who -u 
root     ttyC0    Dec 30 13:45 01:09 
root     ttyp1    Dec 30 14:43   .     (:0.0)
root     ttyp2    Dec 30 15:06   .     (:0.0)
root     ttyp3    Dec 30 13:47 00:28   (:0.0)
root     ttyp4    Dec 30 14:00 00:09   (:0.0)
hacker   ttyp5    Dec 30 15:08   .     (localhost)
root     ttyp6    Dec 30 14:02 00:59   (:0.0)
root     ttypc    Dec 30 14:35 00:09   (:0.0)
# 

Well, that was just simple root and some hacker ssh-ing inside.

As always, check your local  man who page.

Check free space in UNIX - df command tutorial

To check free disk space on our UNIX system we will use UNIX df command.

Standard report after df command will be simmilar to this (note, this is my old IBM R32 laptop with OpenBSD on it):

#df 

Filesystem  512-blocks      Used     Avail Capacity  Mounted on
/dev/wd0a      1389148    296708   1022984    22%    /
/dev/wd0k     13470908   3247728   9549636    25%    /home
/dev/wd0d      2202748       616   2091996     0%    /tmp
/dev/wd0f      3038428    703640   2182868    24%    /usr
/dev/wd0g      1764380    325380   1350784    19%    /usr/X11R6
/dev/wd0h      6578268   1820580   4428776    29%    /usr/local
/dev/wd0j      2799836         4   2659844     0%    /usr/obj
/dev/wd0i      2799836         4   2659844     0%    /usr/src
/dev/wd0e      3348924    102312   3079168     3%    /var 

If you need more readable report, use df with -h option (Human Readable Output):

#df -h

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd0a      678M    146M    499M    23%    /
/dev/wd0k      6.4G    1.5G    4.6G    25%    /home
/dev/wd0d      1.0G    308K   1022M     0%    /tmp
/dev/wd0f      1.4G    344M    1.0G    24%    /usr
/dev/wd0g      862M    159M    660M    19%    /usr/X11R6
/dev/wd0h      3.1G    889M    2.1G    29%    /usr/local
/dev/wd0j      1.3G    2.0K    1.3G     0%    /usr/obj
/dev/wd0i      1.3G    2.0K    1.3G     0%    /usr/src
/dev/wd0e      1.6G   50.0M    1.5G     3%    /var 

If, for some reason, you need report where blocks are not 512 bytes, but one kilobyte, use df with -k option:

#df -k

Filesystem  1K-blocks      Used     Avail Capacity  Mounted on
/dev/wd0a      694574    149968    509878    23%    /
/dev/wd0k     6735454   1623868   4774814    25%    /home
/dev/wd0d     1101374       308   1045998     0%    /tmp
/dev/wd0f     1519214    351820   1091434    24%    /usr
/dev/wd0g      882190    162690    675392    19%    /usr/X11R6
/dev/wd0h     3289134    910290   2214388    29%    /usr/local
/dev/wd0j     1399918         2   1329922     0%    /usr/obj
/dev/wd0i     1399918         2   1329922     0%    /usr/src
/dev/wd0e     1674462     51156   1539584     3%    /var

How to limit report to just one partition ? It's easy, just use df with, say, /home. Also, we will use -h option again:

#df -h /home

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd0k      6.4G    1.5G    4.6G    25%    /home

You can check inode by #df -i:

Filesystem  512-blocks      Used     Avail Capacity iused   ifree  %iused  Mounted on
/dev/wd0a      1389148    249532   1070160    19%    2936   85638     3%   /
/dev/wd0k     13470908   3247744   9549620    25%   17535  865919     2%   /home
/dev/wd0d      2202748       100   2092512     0%      10  155892     0%   /tmp
/dev/wd0f      3038428    703640   2182868    24%   13683  194187     7%   /usr
/dev/wd0g      1764380    325380   1350784    19%    9017  120901     7%   /usr/X11R6
/dev/wd0h      6578268   1820580   4428776    29%   53722  388004    12%   /usr/local
/dev/wd0j      2799836         4   2659844     0%       1  181885     0%   /usr/obj
/dev/wd0i      2799836         4   2659844     0%       1  181885     0%   /usr/src
/dev/wd0e      3348924    102336   3079144     3%    3671  230183     2%   /var 

 

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...