Learning Linux Ubuntu Class notes #3 & #4

in linux •  6 years ago 

I'm still not sure if I am going to love this or hate this, but I am at the beginning of my journey learning  Linux Ubuntu and I have now complete lessons 3 and 4.  I am using STEEM as a learning log and I know sharing my new found knowledge here not only reinforces the learning for me, but also could help others too.

For those of you that missed last weeks post you can check it out here

https://steemit.com/linux/@paulag/learning-linux-ubuntu-class-notes-1-and-2

Additional Notes from weeks #1 & #2

After posting last weeks notes 2 people came forward with awesome remarks.  A big shout out and thank you to @crokkon and @themarkeymark.

 If you use sudo su, you'll spawn a new shell session as user root, running inside the previous user session. While you get to myuser with another su myuser from there, this actually spawns another shell session inside the root session which already runs inside the user session - so you're actually 3 levels deep, not "back". You could just use Ctrl+d (or type exit) from the root session to get back to the original user shell. 

that one was from @crokkon.

@themarkeymark also made a suggestion.  He said 

 Consider using apt dist-upgrade instead of apt upgrade. 

This will  upgrades dependencies. He also supplied this link for further reading

https://ubuntuforums.org/showthread.php?t=2267752

Class #3 Understanding the file system on Linux

A shell is a program which takes input from a keyboard and tells the operation system what to do. Bash is the default shell in linux.

An example input would be

 cal 

which would tell the operating system to return a calendar, 

date

would return the date. 

The command

 cat

 will return the contents of a file.

The file system in linux is set up in hierarchy and last week we looked at navigating this hierarchy with

 cd

The root on linux could be compared to the c drive on windows, however linux and windows have a very big difference.  On windows you can have multiple drives, and when you add the likes of a USB, you add a new drive.  In linux when you add a USB or other drive, it gets mounted into a directories in root.

Everything is a file on linux.  A folder is a file and a file is a file. Below are common files found.  We spend most of the class using 'cd' commands to navigate around the file system.

  • The bin file contains user commands.  There are not system commands but they are necessary.
  • The boot file contains the linux kernel and files needed to boot the system
  • The cgroup  file contains files for networking
  • The dev file contains devices which are attached to your computer
  • The etc file contains system wide configuration files for services that are on the system
  • The home file is like documents and setting in windows
  • The lib or lib64 file are shared libraries use by system programs.
  • The lost+found file will contain corrupt files
  • The media file will contain any mounted media, net is mounted network drives
  • The opt file is for optional software, kinda like program files on windows
  • The prc file contains files used by the kernel
  • The sbin file contains system binary's used by system administrators
  • The srv file is for stuff you are sharing online
  • The sys file contains system files such as network files
  • The usr filer contains user files not necessary to the system
  • The var file contains file who content is changing as the system is running.

Class #4 Understanding Permissions

The command

 ls -l 

will show a list of files with their details for example

drwxr-rw-r--  paula paula 4027 nov 15 19:17 Test

The first letter, d stands for directory and the letters after representing the permissions

The owner is paula, the group is paula , the file size is 4027, the file was last edited nov 15th @ 19:17 and the directory name is Test

owner = Read & Write (rw-)

group = Read (rw-)

other/public = Read (r--)

to change ownership of a file use

 chown user

To change the ownership and group on a file use 

sudo chown user:group file name 

For example a file with the current owner being paula and group being paula, if we wanted to change this to a different group we would use 

sudo chown paula:otheruser Test

After we make a change in group ownership we can run

 ls-l 

and we can see the group has changed.

You can also change the group only by using

 chgrp group_name filename

The file /etc/group contains all the groups defined in the system. You can use the command

 groups 

to find all the groups you are a member of

The command 'chmod' is used to change the permission.  It is written like

chmod {options} filename

Where options are numbers

1 is execute

2 is write

4 is read.

So if you want a file with the permissions rwx-rw-r the options would be rwx(1+2+4)=7 rw(2+4)=6 r=4, 764.  The command would be chmod 764 filename.

You can read more about the permissions here 

https://help.ubuntu.com/community/FilePermissions

 That's my class notes shared and up to-date.  Next week I will share with you the next lot of class notes.


Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

There are so many ways to do the exact same thing with chmod.

The most common chmod command I use is ‘chmod +x somebinary’. It means Add execute privileges to somebinary, so you can run it. I never bothered to memorize the bitwise permissions, +x -x +w -w is easy to remember.

Congratulations @paulag! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 50000 upvotes. Your next target is to reach 55000 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Meet the Steemians Contest - The results, the winners and the prizes
Meet the Steemians Contest - Special attendees revealed
Meet the Steemians Contest - Intermediate results

Support SteemitBoard's project! Vote for its witness and get one more award!

Hi @paulag!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 6.964 which ranks you at #90 across all Steem accounts.
Your rank has not changed in the last three days.

In our last Algorithmic Curation Round, consisting of 213 contributions, your post is ranked at #62.

Evaluation of your UA score:
  • You've built up a nice network.
  • The readers appreciate your great work!
  • Try to improve on your user engagement! The more interesting interaction in the comments of your post, the better!

Feel free to join our @steem-ua Discord server