On Linux - How do I get an HDD serial number of a specific partition? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I need to create a tool that once launched at some directory should print the HDD serial number that the directory exists in.
Is there any way on Linux (e.g. Ubuntu 16.10) to get the HDD SN by path /dev/... ?
I've tried various tools (lsblk, hdparam, ...) but haven't succeeded.

You could use df . to get a device name on which your folder is located.
Then using a name of your device (will be something like /dev/sda2) you could run this command:
udevadm info --query=all --name=NAME_OF_DEVICE_FROM_FIRST_COMMAND | grep ID_SERIAL
The command in 1 line:
df . | tail -1 | awk {'print $1'} | (read name; udevadm info --query=all --name=$name) | grep ID_SERIAL

Related

How to extract file size of the files within .tar.gz using linux command? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have one file with name config.tar.gz. Inside this tar file I have couple of files. Out of which I need to get size of one file.
I am trying following
tar -vtf config.tar.gz | grep sgr.txt
Output:
-rw-r--r-- root/DIAGUSER 109568 2019-11-26 10:16:21 sgr.txt
From this I need to extract only size in human readable format. Something similar to "ls -sh sgr.txt"
You could try:
tar -ztvf file.tar.gz 'specific_file' | awk '{print $3}'

last | reboot in linux rebooted the machine, can someone explain why ? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
how does the pipeline work in the below?
last | reboot
The above rebooted the linux machine.
last search the last logged in user and last output is given to reboot and reboot will reboot the system.
last | reboot
| | => process1 output will be input
process1 process2 for process2
See the man 1 last it says
Last searches back through the file /var/log/wtmp (or the file
desig‐
nated by the -f flag) and displays a list of all users logged in (and
out) since that file was created.
As Daniel says importantly, reboot doesn't care about its input. It probably doesn't read it at all, so piping something in doesn't change its behavior.

How to check which user is positioned in a directory on linux terminal? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
yesterday i was shown that i can't unmount a mounted partition (like /media/test or /mnt/test) if someone is using the terminal in that directory (maybe in ssh connection).
he used a command that listed the user on that directory with pid of process in order to kill the pid and unmount the partitions.
I don't remember the command, could you help me?
ty
This one works nice:
lsof | grep '^bash.*cwd'

List files by using UNIX/Linux commands [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
By using UNIX/Linux commands, pipes (“|”) and redirections (“>”, “>>”)
make a listing of the smallest 5 files in the “/etc” directory whose names
contains string “.conf”, sorted by increasing file size.
This will work:
ls -lS /etc | sort -k 5 -n| grep ".conf" | head -n 5
First list files by size, then sort by 5th column of results by number, then filter lines containing the string ".conf" and finally show only 5 lines.

Is there a trick to show detail description of specific command option in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Is there a trick to show linux command's specific option? Such as I want to know some detail about tar's -z option, and I try this: tar --help | grep '-z' but shows nothing.
So is it possible just show details about specific command option?
Appreciate first if you can help me.
Specifically for the problem of tar --help | grep '-z' not working, do this:
tar --help | grep -- '-z'
Without the --, grep takes -z as an option rather than an argument.

Resources