Vincent Cordes Fall 2011 Opus
OPTIONAL SUBTITLE
This is the revamped introduction.
There is gonna be some stuff and things throughout this opus.
The File system.
With 99% of everything in a Unix system being a file it is important to know how they work, how to find them, and how to modify them.
You cannot execute or open a file without being in the directory the file is in, or making a path to it. This is understandable, it is just slightly annoying.
For some reason I am having the most ridiculously difficult time moving files through directories.
I experienced Shell Scripting.
This is a very powerful tool that can be used effectively with a Unix/Linux system.
The concepts make sense as the CLI simply reads and performs the script line by line.
As far as writing a shell script is concerned I need to learn more about the functions of quotations, back ticks, parentheses to be more effective and create more complex scripts.
The CLI
It is how things get done.
How a CLI could be more efficient, and more powerful (why use it at all?) than a GUI.
I have no prior experience with a CLI and I have a lot to learn to become efficient.
I experienced the awesome that is multitasking on Ubuntu
Linux systems are designed to multitask and it is appropriate for me to finally take advantage of it. It is extremely useful to have the ability to switch work spaces with the click of a button. I hooked up a monitor to my laptop to more effectively use this feature, giving me eight work spaces.
Allows a process to operate while freeing up your terminal. This can be done using bg or &. In addition the process must be able to run in the background.
lab46:~$ bg PID lab46:~$ ./test &
Brings a process operating in the background to the terminal. Use fg to forground a process.
lab46:~$ fg PID
Sends a signal to stop or terminate a process. Killing can be done in a number or ways commands consist of k -0 to -64. Kill usually works in conjunction with the PID (process id) which can be determined using ps. ctrl+c will work to terminate a task in many cases See man page for more. (man kill)
lab46:~$ kill -9 PID
A text editor that is built in to nearly every Unix system. It as different modes consisting of “insert, command, and extended command.” Bi was developed to be efficient and used without a mouse Vi automatically starts in command mode. To enter Vi use vi filename. See http://adminschoice.com/vi-editor-quick-reference for more on Vi.
lab46:~$ vi test
Insert mode allows for text input. There are various methods to enter insert mode. “i, a, A” keys from command mode are just a few. Note that each of these will put you in insert mode at a different point in the text. Follow the link under The Vi Editor for more.
Command mode permits the use of commands within the vi text editor. Use escape to enter command mode. The majority of keys (on the keyboard) are bound to some command. It allows for quick editing of text without a mouse. You can also use a number before some commands to move multiple lines, delete or copy multiple lines, etc. See the link under the Vi Editor for more.
Examples: u = undo dd = deletes a line i = enters insert mode h, j, k, l = move the cursor right, down, up, left
Extend command mode can be used to enter script like commands. To enter extended command mode, from command mode press : (that's colon) This is useful for copying or editing multiple lines at one time. For more on extended command mode see http://www.eng.hawaii.edu/Tutor/vi.html#s-excmd or http://www.uic.edu/depts/accc/software/unixgeneral/vi101.html#introvi
Files are how data in Unix is represented. Fall into one of the three Unix philosophies “everything is a file” this holds true for nearly everything in Unix. Files can be manipulated, executed, used to store data, moved, renamed, replaced, copied, deleted etc. (Given that you have the permissions.) You can create regular files with touch filename, directories can be created with mkdir filename.
Listing files can be done with ls. It is necessary to be able to view the files within a directory in order to manipulate them or navigate through the file system. Hidden files or files that begin with a . can be viewed by using ls -a. For more on ls see man ls.
lab46:~$ ls lab46:~$ ls -a
Permissions dictate who can do what with files. Permissions can be set with chmod. Permissions consist of read write and execute. They can be set for user, group and other. Man chmod for more also see http://www.perlfect.com/articles/chmod.shtml
lab46:~$ chmod 700 test lab46:~$ chmod 755 test
To see the contents of a file (provide you have the permissions) you can open the file with a text editor (vi, nano, etc). It is also possible to see the contents of a file without opening it in a text editor. To do this you can use cat or if you are looking for something specific grep. See man cat and man grep for more.
lab46:~$ cat test lab46:~$ grep this test this is a test lab46:~$
Unix was developed with the idea of multitasking in mind. The Unix system can be easily used to run multiple processes at one time. Multitasking can be accomplished with the use of multiple terminals, foregrounding backgrounding, and workstations. It is one of the core advantages to using a Unix system.
Exposure to open source concepts and ideals.
I will download and install Ubuntu, in addition to applications for the operating system. In addition to reading Harley Hans guide to Unix Linux and learning about the principals Linux systems are based on.
While downloading Ubuntu (free) and some applications after the installation (Emacs to use as an example, also free)I have gotten fair grasp of open source concepts.
Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.
I would say over all I did fairly well. I understand that the important ideal behind open source is not that it is necessarily free but that it can be modified to suit a users need, and that a collaborated effort between an unlimited amount of programmers can make software all around better, faster.
I could improve upon these concepts by contributing to the collective effort. For example creating software for others to use and improve upon.
The process could be extended upon, perhaps by more research into open source, or downloading multiple versions of free Linux.
This enhancement would be relatively inefficient as it is more of a time consuming project that wouldn't necessarily result in learning anything new.
Perhaps by adding a requirement that students make a direct contribution to the open source ideals of some sort (software, knowledge, etc) but that is already tied in somewhat via the opus.
Can I write a Script in Emacs from the desktop and run it in a terminal?
No real resources necessary just Emacs and some knowledge of scripting.
I believe it will work due to the fact that I can run Emacs from a terminal in addition to using it from the desktop shortcut.
I am going to write a small script in Emacs from the desktop and open a terminal to see if it will run.
In Emacs
#!/bin/bash
echo -n “enter a number: ”
read number
let a=number+3
In terminal
chmod 700 test
./test
Based on the data collected:
Yes it worked, I entered a number and it added 3 to that number.
No everything is as it should be.
Nothing that I can think of for what I was trying to test.
My data is sound.
I can say that even with the use of a GUI as opposed to a straight CLI applications will work properly in both/on both/with both.
When multiple processes are running in the background, if you foreground simply fg which one will foreground.
No necessary resources just knowledge of how to use bg and fg. The use of ps is also necessary.
I believe that the process listed at the bottom of the background processes will be the one to come to the foreground. This is really just guess. It would make the most sense without actually knowing what will happen.
I am going to but a number of processes in the background, run ps to see the list, then run fg. After this I will run ps again to see what process comes to the foreground as I will be using xeyes multiple times. I will repeat this until I can determine what actually is happening.
While performing my experiment I initially thought that my hypothesis was correct as the process to foreground was the last process on the list when I ran a ps. However it was also the last process to be sent to the background. I brought other processes to the foreground and found that the last process to be sent to the background (the most recent process in the foreground) would be the one to return to the foreground when performing just fg.
Based on the data collected:
No it was not.
Yes it was applicable, just not correct.
Not really more it just functions differently that I thought it would.
I could probably try with more than just xeyes to see if there is some sort of priority based on a different process.
If I didn't run the experiment enough times the data could be wrong.
I can say after performing the experiment a number of times that the process that will foreground if you are just doing a fg with no modifications to it will be the last process to be sent to the background.
What is the question you'd like to pose for experimentation? State it here.
Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.
Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.
State your rationale.
How are you going to test your hypothesis? What is the structure of your experiment?
Perform your experiment, and collect/document the results here.
Based on the data collected:
What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've
I played with and experienced the C and C++ programming languages.
This is significant as C is important within the UNIX environment. It was an awesome experience. I learned that I can write a program in C or C++ and execute that program from a shell script and then further manipulate the data.
I got to experience what can happen when you try to alter something and don't properly research it first.
It is an important lesson to learn as in the future I may actually have important things on a system that I have control of and breaking it would cause actual problems.
I don't exactly understand what pulgins are or what they do.
I don't know how to fix what I did and I think that would be important in the grand scheme of things.
As an aid, feel free to use the following questions to help you generate content for your entries:
I played around with the command apt-get install
It is an effective way to acquire things from the great internet via a CLI.
Everything makes sense with this command
It is incredibly annoying to download via apt-get install if you do not know the specific name of the package you want
Back in the month of beginning…as it was the beginning month I wish I had known about this
As an aid, feel free to use the following questions to help you generate content for your entries:
I learned about PINE.
It makes e-mail much easier to access
Myself as I had know that there is no way e-mail has to be opened the hard way and I could have asked a question anytime
I know some things can be done, I think some things can be done, and I assume some things can be done.
Wildcards are used in the manipulation and management of files.
lab46:~$ cd src lab46:~/src$ gcc -o hello hello.c lab46:~/src$ ./hello Hello, World! lab46:~/src$
Is the server that you are operating from should you be at that servers location. For example, working on the lab46 server while in the lair.
lab46:~$ cd src lab46:~/src$ gcc -o hello hello.c lab46:~/src$ ./hello Hello, World! lab46:~/src$
Is the server you are operating from should you not be at that location. For example working on lab46 from home via putty or or some version of linux.
/* * Sample code block */ #include <stdio.h> int main() { return(0); }
Is the act of entering command lines into a text editor to be run by the shell when executed.
lab46:~$ cd src lab46:~/src$ gcc -o hello hello.c lab46:~/src$ ./hello Hello, World! lab46:~/src$
Is one of the most important programming languages in existence. C is widely used across numerous platforms for an uncountable number of things.
/* * Sample code block */ #include <stdio.h> int main() { return(0); }
In a nutshell the directory you are currently working in.
lab46:~$ cd src lab46:~/src$ gcc -o hello hello.c lab46:~/src$ ./hello Hello, World! lab46:~/src$
Regular expressions are used for the manipulation of test. They can be used to filter, alter, etc.
/* * Sample code block */ #include <stdio.h> int main() { return(0); }
Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.
If you want to demonstrate something on the command-line, you can do so as follows:
lab46:~$ cd src lab46:~/src$ gcc -o hello hello.c lab46:~/src$ ./hello Hello, World! lab46:~/src$
Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.
If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:
/* * Sample code block */ #include <stdio.h> int main() { return(0); }
Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.
If you want to demonstrate something on the command-line, you can do so as follows:
lab46:~$ cd src lab46:~/src$ gcc -o hello hello.c lab46:~/src$ ./hello Hello, World! lab46:~/src$
Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.
If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:
/* * Sample code block */ #include <stdio.h> int main() { return(0); }
From the file context. Is the removing/deleting of a file. This can be done through the use of rm.
lab46:~$ rm filename
Exposure to command-line tools and utilities.
I will be measuring this objective through my ability to use the CLI.
Throughout the course I have been becoming more proficient using the CLI. When the course began I didn't know anything, (to the point where I couldn't touch a file) now I can do anything from the CLI that I can do from a GUI. (If I can't I at least know where to look to figure it out)
Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.
Fairly well I can work with a CLI infinitely better than when I began.
There are some things that I still have to think about and with Linux systems I would argue that since no one person knows everything there is to know there is always room for improvement.
Perhaps with a written test on the use of various commands and tools provided by the CLI. Asking questions like what can you use for arithmetic? and What would you enter to find the answer to 392385 * 239823? (The experiments and projects performed in the course are a far better test than a test could ever be, so if my opinion matters my method of measurement is better.)
Yes because with a test of this sort it could be efficiently graded via a shell script, and broken down in a matter of seconds to find out what areas a student may know or may need improvement in.
Honestly I would leave it as it is.
Can I get a three dimensional desktop layout for Ubuntu? (aka really cool looking pimped out desktop)
Download compiz.
I believe that I can figure out how to alter my desktop with the use of compiz with relative ease.
I am going to run compiz and check boxes that seem like they will do what i am looking for.
I checked some boxes that seemed like they would give me the appearance I wanted (“cube”) and in order to do this plugins were disabled. I effectively ignored all warnings and proceeded.
Based on the data collected:
No my hypothesis was dead wrong
Perhaps not I really have no understanding as to how compiz works, just what it is supposed to do. I should have looked into it before diving in.
Probably….once again should have gotten a manual.
Research…research….research.
I reiterate, research as opposed to the download and click away strategy.
I can honestly say that there are some things that shouldn't be attempted without a manual or tutorial. My window manager was messed up beyond repair even before doing my next experiment I was looking into a re-install of Ubuntu.
What what will happen if I run sudo rm -rf /?
Among the first things I learned about Linux this is the one command that should never be entered. “Bad” things are supposed to happen.
I believe that sudo rm -rf / will effectively and efficiently shred my file system and make the system unusable within a matter of seconds.
I am under this belief because it should remove nearly all of the files from the system…including the ones that make it work.
I am going to open up a terminal and type sudo rm -rf /.
A bunch of things happened, files were removed, and there were a lot of files that could not be removed. After the command was entered I did an ls expecting nothing to happen and all of the files in my working directory appeared to be there. To be honest I was surprised to find that the system didn't immediately crash.
Based on the data collected:
No and yes. For some reason it appeared that the rm -rf / initially did nothing. This was incorrect as I couldn't even boot Ubuntu when I attempted after a restart.
It was applicable.
If I were to guess there are probably fail safes built into Ubuntu that prevent the absolute nuking of the file system via this command. It may be possible however that the files that were removed were simply not on the surface. I probably should have taken the time to look through the file system in detail to find what was missing. Another “theory” I have is that everything was stored in some form of short term memory and therefore usable until I performed the reboot. (This is however just a theory I will get around to researching it at some point in time.)
I don't think there are shortcomings in the experiment, I had root access and entered the command that should not be entered.
I didn't look through the file system in detail after entering the command, doing so may have provided more insight as to what really happened.
I can say after this experiment that rm -rf should not be entered as it really will make your system unusable. I was looking for an explosive reaction of sorts and got firecrackers (for those people who appreciate metaphors) the firecrackers did end up burning down the house.
I am here today to bash on an experiment performed by Kelly Reed.(More or less prove him wrong because I think he can handle it.) http://lab46.corning-cc.edu/opus/fall2011/kreed11/start#experiment_1. The experiment performed was done in order to test the limit of the numeric value of a variable bash can handle.
So originally while retesting Kelly's experiment I did not use the command let. I simply entered a=1 a=11 etc. Doing it this way provided me far more places that bash can handle than 19 (I didn't exactly pay attention to his steps until after I tested it this way.) I got bored of entering a=1111111111111111111111111….etc and echoing it as I continued to get the return value. So to speed this process up I started to echo $a*$a | bc this also continued to give me an accurate return. (bc does however add in the /) After doing this I was thinking Kelly was crazy so I returned to his opus page to find out how he came to the conclusion that he did. Following his steps using let a=1234567890123456789 returned exactly the results he received. So my conclusion is that bash can handle more than 19 digits but let cannot. (I tried to man let and got nothing so I don't know at all what let's issue is, just that it has one)
Evaluate their resources and commentary. Answer the following questions:
Kelly was of the opinion that bash would handle a number of places (32) or some value divisible by 2.
Follow the steps given to recreate the original experiment. Answer the following questions:
Following the steps in Kelly's experiment I received exactly the same results.
Answer the following:
Answer the following:
The home directory is YOUR directory. It is where all of a users personal files should be kept the only one with the ability to alter anything in a home directory is the user. (permissions, removing, etc) Permissions can be set for other users to enter the directory at all, and or view anything in the directory. Cd will return the user to the home directory for that user.
lab46:~$ "This is what the prompt looks like in the home directory"
Ownership of a file is determined by who created the file. If permissions permit it files can be copied and manipulated from the copy should the owner not want the original file altered.
lab46:~$ touch file lab46:~$ nano file lab46:~$ vi file
Pattern matching is a very useful skill to posses when working with regular expressions. Being able to find a pattern, and tell the system to alter replace or remove parts of or around that pattern makes data manipulation much more efficient.
lab46:~$ cat spring2012-20111103.html | grep "dddefault" <TD CLASS="dddefault">Class</TD> <TD CLASS="dddefault">9:40 am - 11:30 am</TD> <TD CLASS="dddefault">MW</TD> <TD CLASS="dddefault">Classroom C203</TD> <TD CLASS="dddefault">Jan 23, 2012 - May 13, 2012</TD> <TD CLASS="dddefault">Lecture</TD> <TD CLASS="dddefault">Barbara L. Squires (<ABBR title= "Primary">P</ABBR>)<A HREF="mailto:squires@corning-cc.edu" target="Barbara L. Squires" ><IMG SRC="/wtlgifs/web_email.gif" ALIGN="middle" ALT="E-mail" TITLE="E-mail" NAME="web_email" HSPACE=0 VSPACE=0 BORDER=0 HEIGHT=28 WIDTH=28></A></TD>
With this particular example matching the “dddefault” pulls out only the lines with that pattern. The data can be further manipulated to display only the useful information within the file such as the time and location.
The tab key can be used to complete a stuff. (for lack of a better way to explain it) This is very useful in saving time and effort when typing as all you need for a completion is enough of a matching at the beginning of said stuff.
lab46:~$ cat fi(tab) "This is an example"
A program would be code that has to be compiled in order to perform its functions. A process would be run directly from the shell with no compiling required. An example would be a C tetris program vs. cating a file.
Files can be moved and renamed as long as permissions permit whenever wanted or necessary. For example I went through my home directory and created directories for similar files then proceeded to move those files into the directories. Moving and renaming can be done with “mv.” To move a file use mv file destination. To rename a file use mv file newfile.
lab46:~$ mv file Files lab46:~$ mv file newfile
Netiquette is as defined by wikkipedia a set of social conventions that facilitate interaction over networks. From a unix standpoint it would be the social interactions on the network. Proper netiquette would would be respecting users privacy if you happen to have root access and just being generally polite while interacting with other users. Security in Unix is done easily and effectively. With every file needing to have permissions set to people beyond the owner and root as long as no one has the password for root or the UID files and information are secure.
Have you ever wanted to know what it feels like to be able to bring anything your heart desires into existence. With a Linux system you can with little more than a thought. Files of unthinkable power can be created with the touch command, or any text editor.
lab46:~$ touch universe lab46:~$ vi mountain lab46:~$ nano ocean lab46:~$ ./world Hello, World!
Text processing is essentially typing. A text processor such as vi, or nano can save the typed text for later use. The text in the then file can be changed at any time in any way provided permissions.
lab46:~$ vi file Hi Hello Good day Hola
The simplest way I can think to explain directories is to compare them to a windows system. They are kind of like (kind of like) folders in Windows. Directories are used to organize files and I believe they are called directories because of how Linux systems work, with the file system needing paths to locate and utilize files, directories as a term makes sense. You can change directories using the cd command. By itself cd will take you to your home directory, followed by a directory name (cd src) it will take you into that directory, and with a path it will take you wherever you want to go. (cd /home/../usr/games)
lab46:~$ cd src lab46:~/src$ cd lab46:~$ cd /home/../usr/games lab46:/usr/games$ cd lab46:~$
Files within a Linux system can be copied. This is necessary for a million different reasons some examples may be the need to have a back up of the file, or needing to send the file to someone else while still having a “copy” of it for yourself. Whatever the reason copying files can be done with cp. The convenient method to copy text from a file or command line to a file is to highlight the desired text and press the middle mouse button (scroll wheel) if your mouse has one if not a simultaneous right and left click should work at the location you want the text. When copying a file the file with by default copy to the current working directory and it will only copy should you chose a new name for the file. Files can be copied from anywhere to anywhere with permissions and a path.
lab46:~$ cp file newfile lab46:~$ ls file newfile Files lab46:~$ cp file Files lab46:~$ cd Files lab46:~$ ls file
Files in a Linux system can be compressed and decompressed. The compressing a file can be done with gzip, and decompressing a file can be done with gunzip. Compressing is usually only necessary for really large files and or saving space.
lab46:~$ gzip file lab46:~$ ls file.gz lab46:~$ gunzip file lab46:~$ ls file
Understanding and use of pattern matching. To more efficiently collect, sort, or manipulate data patterns are incredibly useful as you need something to match when using regular expressions.
I will find a file with a bunch of unnecessary data and extract the data that I want.
Using the text document I found it was very easy to extract only the data I wanted after finding a pattern to use.
Can I use cron to determine the number of users on the system Tuesday and Thursday at 3:00pm with a small shell script.
UnixMages.com “A run in with Cron”
I think it will work.
Based on my knowledge of shell scripting provided I do it correctly and my knowledge of cron, provided I do it correctly.
I am going to sit in class on Tuesday and Thursday and wait to see if a new file pops up with the number of users contained in it.
I waited in class and my cron1 file updated with the number of users on the system at 3:00 pm.
Based on the data collected:
Cron works exactly as I read it to work. Very successful very pleased.
This was something that I just happened upon and decided to include it as an experiment just to put it in somewhere. So as a question to experimental purposes I am going to propose, can wc -l be used to produce a truly accurate count of users on the system.
Basic knowledge of commands
Yes it will work
I know that wc -l produces a count of lines, so it is just a matter of finding the lines that should not be counted, and not counting them
I am going to find out manually how many users are on the system, at the moment it is just me so that part is easy. I will then look at the lines that should not be included…(using who as opposed to w here) from there I will use a method of not including them and then count the lines with wc -l.
who | grep -v “NAME” | wc -l 1
Based on the data collected:
I can conclude that any count of users I have done throughout the semester has been off by at least 1 possibly more depending on multiple logins and what not due to how wc -l works. I do know now that if I want something that is 100% accurate I have to do a little more work.
If you're doing an experiment instead of a retest, delete this section.
If you've opted to test the experiment of someone else, delete the experiment section and steps above; perform the following steps:
I will be retesting Derik Girard's experiment http://lab46.corning-cc.edu/opus/fall2011/dgirard3/start#experiment_1, his question was can I create a file with a space in the name.
Evaluate their resources and commentary. Answer the following questions:
Something to the extent of I believe it can be done with quotes
Follow the steps given to recreate the original experiment. Answer the following questions:
I used touch “experi ment” and created one file named experi ment
Answer the following:
Answer the following: