LINUX LITE 7.2 FINAL RELEASED - SEE RELEASE ANNOUNCEMENTS SECTION FOR DETAILS


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ls /dev
#1
Hello,

In Chapter 15 of , The Linux Command Line, there is a command -

Code:
sudo tail -f /var/log/messages

It should produce a list and then a SD card is added , it is an example of how the kernel will notice the device and probe it. I can follow the example in the book.
When I run this command (which is not an exercise in the book but I wanted to see it in action) I cannot get a result in terminal myself to then add a USB stick and watch this in action. Maybe the path needs to be different ?

Earlier in the Chapter I had read this -
"quote of Mr.Shotts - First let's look at how the system names devices. If we list the contents of the /dev directory (where all devices live), we can see that there are lots and lots of devices:
Code:
ls /dev
"

This gave me an idea to experiment using the above command, I was trying this below code to determine newly added device names by comparison -

Code:
ls /dev/sd*
My belief was it would show only those with sd naming using the wildcard *, I had learned previously in earlier chapters of "The Linux Command Line" about sd,  and about using wildcard.

Below is a screenshot of my output, and source of my question

[Image: Screenshot_2018_09_21_15_40_46.png]

As you can see I ran the code , I then inserted a USB stick and used up arrow on keyboard to reuse the same code and run it again, thus allowing for a comparison of before and after adding the USB stick.
It produced 2 new results the /dev/sdb and the /dev/sdb1 rather than the 1 new result I was expecting, why is this ?
Reply
#2
I use dmesg -wH for freshly plugged in devices.

Sent from my Mobile phone using Tapatalk
Reply
#3
[member=2]Jerry[/member] Thank You Smile
Reply
#4
No problem Smile

Sent from my Mobile phone using Tapatalk

Reply
#5
Quote:As you can see I ran the code , I then inserted a USB stick and used up arrow on keyboard to reuse the same code and run it again, thus allowing for a comparison of before and after adding the USB stick.It produced 2 new results the /dev/sdb and the /dev/sdb1 rather than the 1 new result I was expecting, why is this ?



My understanding on why the 2 new devices might be rudimentary but it is how I keep things straight.


In the /dev folder it shows the devices as well as the partitions (partitions being treated as a devices also). So you see the /dev/sda (device) and the /dev/sda1 (partition) as well as the new devices like the new usb device which is /dev/sdb (device) and the partition /dev/sdb1 (partition)
Reply
#6
Thank You [member=6935]supergamer[/member]  Smile for explaining .


Reply
#7
Quote:As you can see I ran the code , I then inserted a USB stick and used up arrow on keyboard to reuse the same code and run it again, thus allowing for a comparison of before and after adding the USB stick.
It produced 2 new results the /dev/sdb and the /dev/sdb1 rather than the 1 new result I was expecting, why is this ?

[member=411]bitsnpcs[/member]  I'm not sure what you're trying to do, but it seems that you want to ls into a usb stick? if so, then I think the correct path would be run/media/bitsnpcs, like so:
Code:
$ ls /run/media/bitsnpcs
and then your usb stick should appear in the list just like mine - MOK - does as you can see in the image bellow. 

[Image: 10dh5k4.jpg]

You might want to read here: http://www.tldp.org/LDP/Linux-Filesystem...l/dev.html

Hope this helps! Smile
Without each others help there ain't no hope for us Smile
Need a translation service? https://www.deepl.com/es/translator
Reply
#8
(09-22-2018, 11:51 AM)Moltke link Wrote: I'm not sure what you're trying to do, but it seems that you want to ls into a usb stick?
Hope this helps! Smile
[member=7109]Moltke[/member] thank you  Smile I have read the info on the link you gave me, it was helpful.

The answer by [member=6935]supergamer[/member] is what I needed to know, I cannot mark things solved in this section of forum.

I am not trying to do something at this stage, just experimenting.

What I was curious about, my motivation, was how a GUI only displays the most recently mounted storage device, as the output option field, or how to make a GUI do this.
and
if I could use this command ls /dev/sd* by attaching it to a button in a GUI to achieve similar type of result.

I understand from [member=6935]supergamer[/member] explanation why this did not work in the way I expected, and I also learned some new and useful information on the structure and use from you both. Smile
Reply
#9
Glad to help [member=411]bitsnpcs[/member]

Quote:What I was curious about, my motivation, was how a GUI only displays the most recently mounted storage device, as the output option field, or how to make a GUI do this and if I could use this command ls /dev/sd* by attaching it to a button in a GUI to achieve similar type of result.

Hmmm...I think you could achieve that in python. Are you trying to create/creating a GUI for some specific purpose? May I suggest this program: http://page.sourceforge.net/  I've been playing around with it since last August. It teaches you how to create GUIs using python. From it's website: "PAGE is a cross-platform drag-and-drop GUI generator, bearing a resemblance to Visual Basic. It allows one to easily create GUI windows containing a selection of Tk and ttk widgets. Required are Tcl/Tk 8.6 and Python 2.7+.  PAGE springs from Virtual Tcl, a Tcl/Tk program, forked to generate Python modules that realizes the desired GUI. Tcl is required for running PAGE but is not required for executing the generated Python code." It's not perfect though, I found a bug while using it and reported to it's developer. It seems that the created GUIs won't show properly under python 3.6 - some buttons aren't visible -  wich is the one installed in my system, I had to install python2 so it works as expected. Also, since I've read you're learning python - and so am I by the way  ;D - you might find insteresting this too: https://thonny.org/ it's a "python IDE for begginers" as advertised on its website. Both programs are really light on resources and download sizes are really low, less than 5mb both I think. Page runs as a script so there's no need to install anything. Instructions for installing Thonny are on the link above.

Hope you find this info helpful! Smile
Without each others help there ain't no hope for us Smile
Need a translation service? https://www.deepl.com/es/translator
Reply
#10
Thank you for the links [member=7109]Moltke[/member]  Smile
No not trying to create anything at the moment, I am working through the book, "The Linux Command Line", unsure how many years ago I began it, I began to use Linux (Linux Lite right from the very start) 4 years ago from July 2018. But only started to use Linux and no Windows after a few of those years.
I learn some bits then do other things. When I feel ready then I learn some more. I am just beginning Chapter 17.

I use LL, and Gedit for Python coding, I then test the Python in the terminal before making the GUI, I build the GUI afterwards by editing and typing it in to the Python code in its file.
If you have not seen it this was my first completed Python app and GUI I made, I done it on LL using Gedit, Terminal, Python, and Tkinter. I am really pleased I was able to finish the first one because it will encourage me in future projects, not to give up easily.


https://www.youtube.com/watch?v=yLAAlE5FKoo

Overall in the chapter of book I learned about the storage commands to -
1. make files or folders in to an image
2. command to burn that image/ISO
3. how to clone hard drive to another hard drive
4. how to view what occurs when device is added to the system.

Later that night I was listening to music and looking at the chapter index of contents for next few chapters, a future one is about "archives and backups", my mind thought, you have already learned about backup software, then the thought of commands 1thru 4 and how it may not be too difficult the extra things to learn to make this in Python into a backup software, for files/directories, cloning hard drives, and output it to external media, like portable hard drive or flash drive for files and directories.

Later I thought maybe as a stepping stone to that making an app GUI for burning ISO to disc, or saving to USB could be a practice run, but to make it final /usable gui on its own in case someone liked it or wanted to use it in part of another project.

It was just thoughts of the basic outline of what was needed.

You can get The Linux Command line as pdf free from the official site http://linuxcommand.org/tlcl.php
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)