You are Here:
Linux Lite 5.2 RC1 is now available for download and testing



ls /dev

Author (Read 9040 times)

0 Members and 3 Guests are viewing this topic.

ls /dev
« on: September 21, 2018, 11:55:58 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3180
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
Hello,

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

Code: [Select]
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: [Select]
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: [Select]
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



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 ?
 


Re: ls /dev
« Reply #1 on: September 21, 2018, 12:46:46 PM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 7741
    Posts
  • Country: nz
  • Reputation: 732
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 5.0 64bit

  • CPU: Intel Xeon Dual CPU's E5645 2.4GHz 12 Cores

  • MEMORY: 16Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
I use dmesg -wH for freshly plugged in devices.

Sent from my Mobile phone using Tapatalk
 

Re: ls /dev
« Reply #2 on: September 21, 2018, 12:49:35 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3180
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
@Jerry Thank You :)
 

Re: ls /dev
« Reply #3 on: September 21, 2018, 06:47:32 PM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 7741
    Posts
  • Country: nz
  • Reputation: 732
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 5.0 64bit

  • CPU: Intel Xeon Dual CPU's E5645 2.4GHz 12 Cores

  • MEMORY: 16Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
No problem :)

Sent from my Mobile phone using Tapatalk

 

Re: ls /dev
« Reply #4 on: September 21, 2018, 09:34:13 PM »
 

supergamer

  • Forum Regular
  • ***
  • 163
    Posts
  • Country: us
  • Reputation: 27
  • Linux Lite Member

  • Linux Lite: 3.4 64bit

  • CPU: AMD Phenom 565

  • MEMORY: 12Gb

  • VIDEO CARD: 550 ti
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)
Last Edit: September 21, 2018, 09:36:14 PM by supergamer
 

Re: ls /dev
« Reply #5 on: September 21, 2018, 09:52:10 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3180
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
Thank You @supergamer  :) for explaining .


 

Re: ls /dev
« Reply #6 on: September 22, 2018, 07:51:34 AM »
 

Moltke

  • Gold Level Poster
  • *******
  • 766
    Posts
  • Country: ve
  • Reputation: 90
  • Linux Lite Member

  • Linux Lite: 5.0 64bit

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 5.x
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 ?

@bitsnpcs  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: [Select]
$ 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. 



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

Hope this helps! :)
Without each others help there ain't no hope for us :)
 

Re: ls /dev
« Reply #7 on: September 22, 2018, 10:26:43 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3180
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
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! :)
@Moltke thank you  :) I have read the info on the link you gave me, it was helpful.

The answer by @supergamer 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 @supergamer 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. :)
 

Re: ls /dev
« Reply #8 on: September 22, 2018, 04:10:03 PM »
 

Moltke

  • Gold Level Poster
  • *******
  • 766
    Posts
  • Country: ve
  • Reputation: 90
  • Linux Lite Member

  • Linux Lite: 5.0 64bit

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 5.x
Glad to help @bitsnpcs

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! :)
Without each others help there ain't no hope for us :)
 

Re: ls /dev
« Reply #9 on: September 22, 2018, 09:07:48 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3180
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
Thank you for the links @Moltke  :)
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.




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
 

Re: ls /dev
« Reply #10 on: September 23, 2018, 08:15:56 AM »
 

Moltke

  • Gold Level Poster
  • *******
  • 766
    Posts
  • Country: ve
  • Reputation: 90
  • Linux Lite Member

  • Linux Lite: 5.0 64bit

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 5.x
That GUI looks really good! Nice job @bitsnpcs  :)

Quote
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...You can get The Linux Command line as pdf free from the official site http://linuxcommand.org/tlcl.php
I see. I too started reading that book a while ago and for some reason stopped doing it, guess I got stuck at that moment. Thanks for the link by the way.

Quote
I use LL, and Gedit for Python coding
I used to use gedit too, then tried geany, they both are fine but then I discovered sublime text and find it really nice; lightwight, handy features, easy to use. In the past I've used kate even in windows 7, which is a great editor but now I try to avoid having those kde dependencies and who knows, sometimes I fell like installing it  ::)  Althought, the text editor I use the most is nano, yeah nano all the way. Now that I think of it, nano's the reason I never really care too much for text editors.


If you fell like trying sublime text, here are the steps for installing it:


First, open a terminal and type
Code: [Select]
$ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -


Code: [Select]
$ echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list

Code: [Select]
$ sudo apt-get update

Code: [Select]
$ sudo apt-get install sublime-text


Or, you can simply read more about it on its website http://www.sublimetext.com/


Cheers! :)
Without each others help there ain't no hope for us :)
 

Re: ls /dev
« Reply #11 on: September 23, 2018, 11:31:01 AM »
 

trinidad

  • Platinum Level Poster
  • **********
  • 1151
    Posts
  • Country: us
  • Reputation: 187
  • Linux Lite Member
    • dbts-analytics.com

  • Linux Lite: 5.0 64bit

  • CPU: AMD A8 5500 4 cores

  • MEMORY: 8Gb

  • VIDEO CARD: AMD/ATI Radeon HD 7560D

  • Kernel: 5.x
@Moltke wrote: "text editor I use the most is nano, yeah nano all the way"
I agree. Use Nano a lot myself for BASH stuff, and whatever other editor is available depending on the OS when it's necessary to be out of the CLI, and I use only Gvim for other code bases like ruby and js. I don't know if it's an attempt at a teaching method, but in a lot of tutorials I see text editors recommended for basically no particularly important reason when nano would be the easiest. Small changes might as well use a small editor.

TC
All opinions expressed and all advice given by Trinidad Cruz on this forum are his responsibility alone and do not necessarily reflect the views or methods of the developers of Linux Lite. He is a citizen of the United States where it is acceptable to occasionally be uninformed and inept as long as you pay your taxes.
 

Re: ls /dev
« Reply #12 on: September 23, 2018, 01:57:41 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3180
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
Thank You @Moltke  :)   it is on Github, if you want, I made gui in way so I (and others) can make other GUI from this easily by copy/paste and edit.

Earlier I made some Gimp edits to try and better show how the thought image and book commands arrived in 1 thought. It took me a lot longer to try and do this.

Maybe it helps someone if it is interesting, it is not a project, or meant to be accurate, it is just showing the process of my thought as images when learning.


The image/thought was based on Systemback as this is the only backup software my eyes had seen.









The image didn't have the highlight, I just use it to show the description below of commands from book and the ideas of how I thought they might be able to be used from a beginner perspective, but likely wrong lol.

1 -  ls -t /directory/of/images       display image filenames of backups made of HOME at #3, and list by date order.

2 - ls /dev/sd*    output destination box, drop down menu for selection of sd* locations

3 - ??  needs command to create an image file from collection of HOME directory contents

4 - dd if=/dev/sdb of=flash_drive.img        need to change command to make image of entire OS not of the example flash_drive

5 - ??  run install media from #4

6 - dd if=input_file of=output_file [bs=block_size [count=blocks]]         where input file is output of/ or stored image of  #4

7 - sudo fsck /location/of/file system          file system check and repair

8 - sudo apt-get update
     sudo apt-get upgrade

9 - add embedded text window, mirroring the terminal output inside the GUI from #6 so any errors are visible.


@Moltke maybe now you can see why I said it was just thoughts based on the commands as I don't know enough to do this, many others would know though.
After the image thought, in popped its description thought -

"Bubl is a blend of LL, Cli, Python and Tk, cooked at 420F and seasoned with Love :) "
Last Edit: September 23, 2018, 04:24:00 PM by bitsnpcs
 

Re: ls /dev
« Reply #13 on: September 23, 2018, 02:45:52 PM »
 

Moltke

  • Gold Level Poster
  • *******
  • 766
    Posts
  • Country: ve
  • Reputation: 90
  • Linux Lite Member

  • Linux Lite: 5.0 64bit

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 5.x
@Moltke wrote: "text editor I use the most is nano, yeah nano all the way"
I agree. Use Nano a lot myself for BASH stuff, and whatever other editor is available depending on the OS when it's necessary to be out of the CLI, and I use only Gvim for other code bases like ruby and js. I don't know if it's an attempt at a teaching method, but in a lot of tutorials I see text editors recommended for basically no particularly important reason when nano would be the easiest. Small changes might as well use a small editor.

TC


@trinidad  Yeah, nano's the one I always use the most. I very often find myself typing
Code: [Select]
$ nano somefile in a terminal. I'm so used to it and have learned its key shortcuts...well most of them  8) Vim, Vi, Gvim I've always wanted to learn how to use Vi/Vim since I read a lot of articles claiming its not just one more editor but THE EDITOR LOL, but its "user unfriendliness" makes me always type the one Vi/Vim command I ever learnt :q!  ;D

@bitsnpcs I can only say: WOW! Nicely done girl! Like I said in a previous post I'm just learning how to create GUIs with python  ;D using those two programs I told you about.
Last Edit: September 23, 2018, 02:51:30 PM by Moltke
Without each others help there ain't no hope for us :)
 

Re: ls /dev
« Reply #14 on: September 23, 2018, 02:53:19 PM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 7741
    Posts
  • Country: nz
  • Reputation: 732
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 5.0 64bit

  • CPU: Intel Xeon Dual CPU's E5645 2.4GHz 12 Cores

  • MEMORY: 16Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
nano ftw :)

Sent from my Mobile phone using Tapatalk

 


Tags:
 


Linux Lite 5.2 RC1 is now available for download and testing