FreeBSD Display Information About The System Hardware

Posted on in Categories FreeBSD, Hardware, Howto last updated January 26, 2008

FreeBSD comes with different utilities, which can be use to gathered the information as per your needs. uname command is use to print system information. dmesg command is use to print kernel ring buffer information. sysctl command is use to configure kernel parameters at runtime as well as to read hardware information.

Following list summaries, all the command you need to gather FreeBSD hardware information.

1) Determining the Hardware Type/platform:
# uname -m
2) Determining machine processor architecture:
# uname -p
3) Determining FreeBSD release level:
# uname -r
Generally, following command is use to get all info at a time:
# uname -mrs
Output:

FreeBSD 5.0-RELEASE i386

4) Determining CPU information such as speed, make etc
# dmesg | grep CPU
Output:

CPU: Pentium 4 (1716.41-MHz 686-class CPU)
acpi_cpu0:  on acpi0
acpi_cpu: CPU throttling enabled, 8 steps from 100% to 12.5%

5) Determining real and available memory to FreeBSD:
# dmesg | grep memory
Output:

real memory  = 201326592 (192 MB)
avail memory = 188555264 (179 MB) 

Alternatively, try following command to grab memory information:
# sysctl -a | grep hw.*mem
# sysctl -a | grep mem

Output:

hw.physmem: 194985984
hw.usermem: 167641088
hw.cbb.start_memory: 2281701376

Note systcl has more info, just type the sysctl command to see rest of all information:
# sysctl -a | less
6) Determining how long a system has been up:
# uptime
7) Determining when a system was last rebooted or shutdown:
# last -1 reboot
# last -1 shutdown

8) Determining swap file system usage
# swapinfo -k
9) Determining who is logged in and what they are doing. Following all commands can be used. users command displays the list of all logged in users only.
# w
# who
# users

10) Find out when user was last logged in – You can use last command as follows:
# last user-name
(a) To find out user vivek was last logged, enter:
# last vivek

See FreeBSD getsysinfo.bash script. It is use to find general FreeBSD system information such as, hostname, OS version, Kernel version, Processor/CPU, Total RAM, System load, network interface, total logged in users, Hard disks, Runlevel etc. Make sure your read the detailed installation instruction.

FreeBSD > Init to reboot or shutdown system

Posted on in Categories News last updated February 23, 2005

FreeBSD init works different ways. In BSD style, it specifies the kernel security level as follows:
-1: Permanently insecure mode.
0: Insecure mode
1: Secure mode
2: Highly secure mode
3: Network secure mode

You can get current security level (FreeBSD runlevel) using sysctl command:
# sysctl –a | grep kern.securelevel

You can setup new security level in /etc/rc.conf file:
1) Open file in text editor
# vi /etc/rc.conf

2) Add or modify following:
kern_securelevel_enable=”YES” # kernel security level
kern_securelevel=”2″ # range: -1..3 as above

3) Save the changes. Exit and restart FreeBSD.

If init used from command line i.e as a user process, init will emulate AT&T System V UNIX behavior as follows:

0: Halt and turn the power off
1: Go to single-user mode
6: Reboot the machine
c: Block further logins
q: Rescan the /etc/ttys file

1) To halt and turn the power off type:
# init 0

2) You can also use normal halt or shutdown command to shutdown system.

FreeBSD > Sending a Message by E-Mail

Posted on in Categories News last updated February 23, 2005

E-mail is a way of sending a message between users and administrators from command prompt for shell script. Use mail command as follows

mail -s “Subject” username-name or email-id
email message
email message
…
..
When the message is complete, press Control-D or type dot character and press return/enter key.

1) To send email to root user to notify printing problem
mail -s “printing problem” [email protected]

Hi Admin

I am having problem with printing can you please check up what is wrong with it. It was working fine untile late evening after that it is not printing from my HP-UX workstation.

Thanks

Joy D.

Please note you can also use webmail program form your web browser or other mail client if already configured.

FreeBSD >Sending a Message to All Users on a Remote UNIX/Linux/FreeBSD System

Posted on in Categories News last updated February 23, 2005

Traditionally we used rwall command to send a message to every user on a network. Rwall works over insecure network. Instead of that, we can use wall command over ssh as follows, which is more secure and works with almost all UNIX variant.

1) ssh with wall syntax is as follows, after EOF press enter/return key and type message. When the message is complete, type EOF:
$ ssh [email protected] wall<&ltEOF
message1
message2
…
…
EOF

2) To display message “Kernel is upgraded on this server. System is schedule to reboot in 45-minute time. Please logout and save your work” to ever user on remote FreeBSD system pweb.test.com

$ ssh [email protected] wall <&ltEOF
Kernel is upgraded on this server $(hostname).
System is schedule to reboot in 45-minute time.
Please logout and save your work.
Current local data and time is $(date)
EOF

Please note it might prompt for password if ssh-keys not used. Once password supplied it will execute wall command on remote server pweb.test.com. In order to work this remote UNIX/BSD/Linux must have sshd (ssh server) running. Also, notice that we have executed hostname and date command using command substitution feature of shell. This tips also works with Linux and other UNIX like operating system.

FreeBSD >Sending a Message to All Users on a System

Posted on in Categories FreeBSD, Howto last updated November 20, 2006

You can use the wall command to send a message to every user on a system. General syntax of wall command is as follows:
wall
Message
Message

….
..
When the message is complete, press Control-D.

1) To display message “Disk failure system will be down for 30 minute” to all users use wall as follows:
# wall
Disk failure system will be down for 30 minute
--UNIX Admin
--MyCorp.com

When the message is complete, press Control-D (CTRL+D) to send message to all user.

2) To display message “Web server under DOS attack, come to IDC # 3” to all WHEEL group member use wall command with –g option as follows:
# wall –g wheel
Web server under DOS attack, come to IDC # 3 to investigate matter further.
-- IT HEAD

When the message is complete, press Control-D (CTRL+D) to send message to all user.

FreeBSD > Sending a Message to an Individual User

Posted on in Categories News last updated February 23, 2005

You can send a message to an individual FreeBSD user logged into system using the write command. Typically writing a short message to an Individual user is main usage.

1) Use write command as follows
$ write user-name
Your message
Your message
…
When the message is complete, press Control-D

2) Here is an example of a message:
$ write joy
Do not use IRC in C Lab session.

3) Following message will be displayed on joy’s terminal:
Message from [email protected] on ttyp0 at 13:24 …
Do not use IRC in C Lab session.