Today I continued working with the CLI. I went over the su (switch user) command again, the whoami command, and the sudo adduser command. I then went over permissions again (read, write, execute(rwx)) for the different entities (user, group, other(ugo)). This structure means there are 9 permissions for each file, (rwx) for each of the three levels of ownership (ugo). The ls -l command shows the various permissions for the entities on a file. For example, in drwxrwxr-x, the first letter stands for drive, the first rwx means the owning user can read, write, and execute, the second rwx means the owning group can read, write, execute, and the last t-x means the "other" entity can read and execute, but NOT write.
The "q" key will have me exit a file (or ctrl X in some cases). The "less" command, followed by the file name, will open a file. The nano command will allow me to create a file. I can then save it during the prompts that come up by exiting the file. I can change the permissions for the various entities with the chmod (change mode) command, followed by what I want to change and the file that needs to be changed, like so:
chmod o-x hello.txt would remove execute permissions from the other entitity
chmod -x hello.txt would remove the execute permission from all three entities
chmod +x hello.txt would add the execute permission from all three entities
Below is some of my work today:
The "q" key will have me exit a file (or ctrl X in some cases). The "less" command, followed by the file name, will open a file. The nano command will allow me to create a file. I can then save it during the prompts that come up by exiting the file. I can change the permissions for the various entities with the chmod (change mode) command, followed by what I want to change and the file that needs to be changed, like so:
chmod o-x hello.txt would remove execute permissions from the other entitity
chmod -x hello.txt would remove the execute permission from all three entities
chmod +x hello.txt would add the execute permission from all three entities
Below is some of my work today:
We went over octal notation today. Decimal notation looks like this:
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
So, under decimal notation, the 10 means one 10 and 0 ones. Meanwhile, octal notation looks like this:
0 1 2 3 4 5 6 7
10 11 12 13 14 15 16 17
So, under octal notation, the 10 means one 8 and 0 ones. So, for example, in octal notation, 22 is two 8's and 2 ones.
So, when using chmod, we can say this:
chmod 777 hello.txt
Which would give ugo rwx capability. This is because each permission is a assigned a number, read is a 4, write is a 2, and execute is a 1. So if I want to give read, write, execute permission, that is a 7. The first number corresponds to the user entity, the second number to the group entity, and the third number to the other entity.
chmod 640 would allow the user rwx, the group rw-, and the other ---.
The code above uses the chown (change ownership) command. This command must be preceded by the sudo command (this allows you to act as a super user) in order for it to work. So, you would enter:
sudo chown mike newdoc.txt
This would change the user from treehouse to mike. If we wanted to change the user AND the group from treehouse to mike, we would do this:
sudo chown mike:mike newdoc.txt
The commands "less," "more," and "nano," followed by a file name, can be used to view a file or modify a file. In reference to a text file, more prints the file contents to the bottom of the CLI, less jumps into the file contents (I can jump back out with "q"), and nano also jumps into the file contents, but allows me to modify the contents and save before exiting.
The command !! will show the previous command that we ran. This is useful when you entered a command that needed sudo, but forgot to type sudo, that way you don't have to type everything in again. So, on the new line, you would enter "sudo !!" and that would work.
The "top" command opens a task manager on the CLI. Hitting the question mark will bring up the help menu. Hitting q takes you out of the program. The "clear" command will clear the screen. The ps command will show you the programs running in the shell, which is usually bash (the shell itself) and ps, which you just opened with the ps command. The ps aux command will show a snapshot (non-updating) of the tasks running. The PID column shows the process id. This command will search the list of processes for the process with the search term in it:
ps aux | grep "search term"
When in a document (with nano, for example), we can hit "ctrl z" and the program we are in will be paused, to allow us to enter commands in the CLI, without having to save or quit the program and exit it. The "fg" command (foreground) will take whatever we most recently paused and bring it back to the foreground. The "jobs" command will print the list of jobs in this session. You can run multiple jobs and bring them to the foreground with the fg command followed by the job number, such as:
fg 1
That would bring job 1 to the foreground. This command will open up the task manager in the background, in case you want to open it up, but look at it later:
top &
The & opens a program in the background. A signal is a message sent to a process by the operating system. The "term:" signal, short for terminate, requests that the process terminates after any cleanup. The "ctrl c" command will send a term: signal to a process that you are running. The "kill" command followed by the PID number for the process will tell a process to terminate itself. The "kill -9" command will terminate a process completely (as opposed to telling a process to terminate itself), but this can leave the computer/files in an unusual state, so we want to use this only if other methods to quit a process are not working. With the "kill -STOP" command, followed by the PID, we are sending a signal to pause/stop the program, the same as "ctrl z," except we don't have to be in the program to do it. So, the kill command isn't just used to completely terminate a program.
kill -kill, kill -sigkill, and kill -9 all turn a process off immediately.
SUMMARY OF CODING SKILLS
Total Treehouse Points: 3,666
Treehouse Points by Subject Matter: HTML 663, CSS 1,599, Design 1,193, Development Tools 181, and Miscellaneous
Treehouse Ranking (%): "You have more total points than 85% of all students."
Badge(s) Earned Today:
Console Users and Permissions
Console Processes
Courses Completed:
How to Make a Website
HTML
CSS Foundations
CSS Layout Techniques
Aesthetic Foundations
Design Foundations
Photoshop Foundations
Design Foundations
Photoshop Foundations
Books Read or in Progress:"Head First HTML and CSS," by E. Robson & E. Freeman (In progress, I've read the 37 pg. preface and the first 255 pgs. of actual content, which is the HTML section of the book)
Hours Spent Coding Today: 4.5
Total Hours Coding: 214.5
No comments:
Post a Comment