LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command Questions (https://www.linuxquestions.org/questions/linux-newbie-8/command-questions-4175572187/)

asw225 02-13-2016 02:08 PM

Command Questions
 
Hi All,

I am trying to learn commands in linux. The man command is helpful to an extent. However, I was hoping you all could help provide a more layman understanding of the below commands. Links to recommended sources for more information would be great if you are aware of any.

1. ls /dev/sd*

2. cat /etc/fstab

3. df -h

4. free -m

Thanks!

pan64 02-13-2016 02:16 PM

I do not really understand what is your problem with 4, 3 and 2, would be nice to explain what is your problem with that exactly. I think those commands are quite simple, the most difficult one is probably the first one. /dev/sd* means all the disks you have, so ls /dev/sd* will list your disks. In order to understand it you need to be familiar with /dev and its content.

ardvark71 02-13-2016 02:20 PM

Quote:

Originally Posted by asw225 (Post 5499710)
4. free -m

Hi...

The "free" command deals with memory usage (and availability) in Linux. the "-m" tells the program to present information in MB's. Please see here for more information. :)

Regards...

asw225 02-13-2016 02:23 PM

Sorry Pan64, I am brand new to linux.

I just started going for a degree in IT. This is a new world for me. Bare with me please :). I just started a course in Linux and am messing around with commands. I am looking to get a better perspective at what I am dealing with.

jpollard 02-13-2016 02:24 PM

#1? do you want the ls command, or what you are looking at after using the command?

ls (with no options) just lists filenames...

The /dev/sd* lists all files that start with /dev/sd. As a side note, you get the same thing with "echo /dev/sd*", though the result is all one line. Now, if you want an explanation of what all the files are that exist in /dev, that is a different question.

#2 do you want the cat command, or what you are looking at after using the command?

cat by itself copies the contents of one or more files to stdout... (which happens to be the terminal)
The contents /etc/fstab is a list of filesystems to be mounted during system boot, or to use filling in missing options from the mount command. The manpage on fstab describes each field of that file... and the manpage on mount will explain that command.

#3 df reports on disk usage (df itself is short for "Disk Free"). The -h option requests the units to be more "readable". The "readable" part is that the size of disks are now in the TB range, so displaying them in units of 1K blocks makes the number really large. The default units is 1K (historical default - it made sense when the largest disk was only 5MB to 10MB. Even now, for some partitions, it can still make sense.)

#4 free reports the memory and swap usage (though it is a bit vague). This was more useful when system memory was quite small - and running out a severe problem. Now, it is mostly useless; it can be used to recognize when something sucks up all of memory (and will overflow into swap) but other than that, not very useful.

pan64 02-13-2016 02:30 PM

Quote:

Originally Posted by asw225 (Post 5499720)
Sorry Pan64, I am brand new to linux.

I just started going for a degree in IT. This is a new world for me. Bare with me please :). I just started a course in Linux and am messing around with commands. I am looking to get a better perspective at what I am dealing with.

I think you read the man pages already, so I won't copy them here. But actually we need to know what caused your confusion to help you.

asw225 02-13-2016 02:45 PM

I do appreciate all of your input!

So ls lists files, and /dev/sd* lists the disks I have. This might be a stupid question, but what type of disk are they referring too?

My questions may be elementary so feel free to share recommended websites or youtube videos so I can learn more.

jpollard 02-13-2016 03:26 PM

Quote:

Originally Posted by asw225 (Post 5499734)
I do appreciate all of your input!

So ls lists files, and /dev/sd* lists the disks I have. This might be a stupid question, but what type of disk are they referring too?

My questions may be elementary so feel free to share recommended websites or youtube videos so I can learn more.

Actually, the kernel has unified SATA, SAS, SCSI, ATA/PATA, and USB disks under the SCSI name (that is where the "s" came from). They all had similar command sets (usually a subset of the SCSI commands) so the drivers are now three levels: a device driver interface, the SCSI layer to pass disk commands around with, then a controller layer (which where the controller variations get handled, and any I/O commands translated). The devices not under this are the SD cards not attached to a USB. These show up as a /dev/mmcblk* (as used on the RaspBerry Pi).

There are some other interesting references to the same disks: /dev/disk/by-id identifies the vendor/model/serial number the disk reports. the /dev/disk/by-label identifies the filesystem labels given to disk devices. The /dev/disk/by-path provides access by identifying the controller connections (on pcs the PCI addressing) where available. Then there is /dev/disk/by-uuid which uses the UUID.

There are also logical volumes(I belive it is /dev/lv*, though I don't have any at this time), the multiple disk driver layer (/dev/md*) all of which reside in /dev.

BW-userx 02-13-2016 04:43 PM

Quote:

Originally Posted by asw225 (Post 5499710)
Hi All,


2. cat /etc/fstab


Thanks!

prints out contents of fstab to term screen

JJJCR 02-14-2016 08:59 PM

My 2 cents. For question number 1 & 2:

1 - ls /dev/sd*

refer to this link: http://www.linfo.org/wildcard.html

or search the web for Linux wildcard operators :)

2 - cat /etc/fstab

prints the output of any text file to the screen or basically view the content of the file without opening it.



Cheers.. Good luck! enjoy learning..

jpollard 02-14-2016 09:12 PM

Quote:

Originally Posted by JJJCR (Post 5500288)
My 2 cents. For question number 1 & 2:

1 - ls /dev/sd*

refer to this link: http://www.linfo.org/wildcard.html

or search the web for Linux wildcard operators :)

2 - cat /etc/fstab

prints the output of any text file to the screen or basically view the content of the file without opening it.

Actually, cat opens the file...

Now if you mean without EDITING the file, then yes (editing would be a different command). But there is no way to know what is in a file without opening it and reading at least part of the file.
Quote:



Cheers.. Good luck! enjoy learning..

JJJCR 02-14-2016 09:21 PM

Thanks for the heads up, Jpollard.

Yeah technically, no way to read the file without opening it. :)

BW-userx 02-15-2016 07:16 AM

Quote:

Originally Posted by JJJCR (Post 5500288)
My 2 cents. For question number 1 & 2:

1 - ls /dev/sd*

refer to this link: http://www.linfo.org/wildcard.html

or search the web for Linux wildcard operators :)

2 - cat /etc/fstab

prints the output of any text file to the screen or basically view the content of the file without opening it.



Cheers.. Good luck! enjoy learning..

@JJJCR you did not answer #2 correctly. that command will not "prints the output of any text file to the screen". cat /etc/fstab only prints out the contents of fstab.

5 point penalty

hahaha :p

stick to the question at hand.

Blitzig 02-15-2016 09:23 AM

First you would need to know the meaning of the 4 commands you have in question and then the options alongside them.

ls = The ls command is used for listing. There are many options for this command depending on how you would like to list files in a directory.
/dev/sd* = This directory contains files for the system devices. The sd* revers to your HDD's . They normally start with sda then sdb and so forth. You will also see
sda1 for example, which indicates there is a partition on the drive. The "1" refers to the first partition on the drive.

cat = The cat command is used to view the contents of a file such as config or normal text files.
/etc/fstab = The fstab file contains the mount points that will be mounted on boot. You can configure the fstab file and add other mnt points that you would like to be mounted on boot

df -h =
This command will list your filesystems
-h = The "-h" option lists the filesystems in human readable format.

free =
This command will display the system memory such as the physical memory as well as swap.
-m = This will display the memory in mega bytes

BW-userx 02-15-2016 09:48 AM

Quote:

Originally Posted by JJJCR (Post 5500296)
Thanks for the heads up, Jpollard.

Yeah technically, no way to read the file without opening it. :)

unless you got super guru mind powers :D

Soadyheid 02-15-2016 10:04 AM

Have you heard the one about write-only-memory...? :)

Play Bonny!

:hattip:

hydrurga 02-16-2016 05:02 PM

Quote:

Originally Posted by JJJCR (Post 5500296)
Thanks for the heads up, Jpollard.

Yeah technically, no way to read the file without opening it. :)

Unless you read the file's raw data blocks directly. Technically you're not opening the file... ;-)

jpollard 02-16-2016 06:34 PM

:-) I thought about mentioning file system debuggers. But you have a very hard time accessing the raw data blocks directly. You CAN open the disk device... but then you have to interpret the filesystem architecture to find the blocks...


All times are GMT -5. The time now is 12:46 AM.