How to view dmidecode output? - linux

I wanted to use the dmidecode command to retrieve serial information of a remote machine (server). In sites such as this they mention "output", but when I type it into my prompt, it just stays blank. Any help would be appreciated!
# dmidecode -t system

If you're literally typing that into the terminal, nothing is happening because it's considered a comment. What they mean by the # is that it should be run as root. So try: sudo dmidecode -t system.

Related

Issuing Command Via SSH Prompts for Password

I'm having an issue with a script used in a project I inherited that has little to no documentation, and am in the process of documenting everything. I'm trying to debug an issue with one line of a script that is executed on the host machine to call out to a LAN-attached Raspberry Pi with SSH to return some information about the Pi.
We already have working versions of this Raspberry Pi which can execute the script without issue, and I'm not sure what the difference is. When executed on the new one, it prompts for the root password on the Pi, but it has not done this on previous versions of the device. I assume it has something to do with the SSH configuration but I don't know enough about SSH to say what would be the cause.
The line in particular causing the issue is:
ssh -o StrictHostKeyChecking=no {host_name} uname -a &>/dev/null
rc=$? #gets the return value of the remote command so we can read the uname info
{host_name} of course is the actual host name it's connecting to, but I've left that part out for privacy reasons. The script is the same on both machines.
Both Pi devices are the same model and I'm having trouble narrowing down what could cause me to not be able to execute this command. Does anyone know what I need to configure in order to be able to execute this command on the Pi remotely?
Quick fix:
sshpass -p 'password' ssh -o StrictHostKeyChecking=no user#server
Detailed fix:
Most likely you would need to set up Async keys (public/Private) for proper passwordless login. Your command does not show you are using keys so I'm assuming you are not (e.g. -A or -i /path/to/key). Generally root user is blocked (I guess not your problem), I would set up another user for this or change sshd config. You could also Compare the sshd configurations between the Pi Boxes.
See: https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md
Okay, so after some more digging around, I discovered that there was a separate .ssh directory under /root that contained an authorized_keys file. After copying this to the new Pi, it worked. I had been wondering all this time if there was a separate config folder for root, but I've never gone digging around /root, so I wasn't aware that it was there.

get info from nmcli linux shell script

I am making a script in shell and I want to extract information from the command nmcli.
If I execute nmcli -p dev wifi list in a linux terminal I get a table with all Wi-Fi available. From each Wi-Fi (SSID) in the table I want to get only the SECURITY field.
So the output of the script would be something like:
SSID1 : SSID1-SECURITY
SSID2 : SSID2-SECURITY
... : ...
I've been searching for a while but haven't found how to do it :(
Can someone tell me how to get the security field from each SSID?
Thank you very much.
Don't know much about nmcli, but I think you can do :
nmcli -p dev wifi list | grep 'SSID.*SECURITY'

What do these 'smbclient' samba information mean?

On a gentoo Linux I am making a call to smbclient, which among others show the following output (when connecting to a Windows share on some Windows computer):
Domain=[LN_DOMAIN] OS=[Unix] Server=[Samba 3.6.24]
What do these information tell me? Especially, what is the number '3.6.24' in the last part? It looks like a version number, but /usr/bin/smbclient -V returns:
Version 3.0.33
So what does the number 3.6.24 mean? There does not seem to be anything on the man pages.
Full example to reproduce this outcome (run on the Linux client, to list the content of a directory on a Windows share on a Windoes7/Windoes XP machine):
/usr/bin/smbclient "//123.123.123.123/Backup" "password" -U "username" -W "workspace" -D "Directory" -c "ls"

Get DIMM & CPU Socket Information

I want to get number of RAM slot (DIMM) and CPU socket of a PC in Linux.
In Linux, there's a command dmidecode but this command must run with sudo/root permissions.
Anyone can tell me another solution to get DIMM & CPU socket without using sudo/root permissions.
The only thing that has information is the SMBIOS / DMI, and the only way to get access to this is via /dev/mem.
If you're concerned with a user having too much privilege with sudo, then you can add the specific permission to run dmidecode by a particular user:
example stub from the sudoers file:
# Cmnd alias specification
Cmnd_Alias DMI_COMMANDS = /usr/sbin/dmidecode -t memory
dmiuser ALL= NOPASSWD: DMI_COMMANDS
This allows the dmiuser account to execute only the command dmidecode -t memory (without a password in this case).

sending raw data through usb on linux

I'm printing some labels on a Zebra TLP-2844 printer, and have been doing it fine on Windows by sending the EPL instructions to the shared USB printer as follows:
type Label.prn > \my-pc\zebra
and it seems to work with serial ports too, with
type Label.prn > COM1
Now I'm trying to to the same on Linux, but it's getting really hard! My first guess was:
cat Label.prn | /dev/bus/usb/005/002
since my printer is on bus 005, device 002 (checked it with lsusb command) but it doesn't work at all, as I get the following:
bash: /dev/bus/usb/005/002: Permission denied
Any guesses?
The command you did
cat Label.prn | /dev/bus/usb/005/002
will try to run /dev/bus/usb/005/002, which is not executable, hence "permission denied".
The correct command would be, similar to windows
cat Label.prn > /dev/bus/usb/005/002
However, not sure if you actually can write anything to a printer like that in linux. If the printer is set up properly, you might also try:
lpr Label.prn
In case anyone else is trying to access raw USB printer ports; The "permission denied" problem is circumvented by adding your user to group "lp", like so:
$ sudo usermod -aG lp USERNAME
where USERNAME is your username.
Sorry by My english.
I tested here, my printer TLP2844 connect on USB, in my embedded arm9 board with linux.
I typed in command prompt:
printf "OD\r\nN\r\nD5\r\nS2\r\nZT\r\nQ128, 24\r\nq400\r\nA15,10,0,2,1,1,N,\"TESTE\"\r\nP1\r\nFE\r\n" > /dev/lp0
and... the TEST printed
You should change access mode for /dev/usb/lp0 device: sudo chmod a+w /dev/usb/lp0
And then you can print a label using copy command: cp test.zpl /dev/usb/lp0
Also you can create your own build system in Sublime Text for example:
{
"cmd": ["cp", "$file", "/dev/usb/lp0"],
"encoding": "utf8"
}
and send files to the printer by pressing Ctrl+B keys immediately after finishing edit the label.
Or you can try my tool to send zpl labels to the printer via TCP/IP:
https://github.com/kashamalasha/AutoIt_ZebraTester
It was written on AutoIt Script language, so you need to install AutoIt to build it. Unfortunately there is no description on English, only Russian, but I can write it very soon, if you will need it.

Resources