Cloud Shell hw6 - Michael Witusik
One of the things that I started off doing was simply looking through the help section of bash using the “help” command. Although this is a utility, I wont use it for my 3 that I talk about. Going through the many different commands, I went ahead a chose a these: cat, ls, and chmod.
First, I used cat to create and write to my file. cat stands for concatenate and the command allows us to create, view, and concatenate files.
Now, if I try to run this file you should get an issue such as this:
This is where the ls and chmod commands come into play.
the command “ls” allows for a user to show all files in a directory, or a specific one if provided. There are also many arguments you can pass it. In my example I am using the full command “ls -al”. adding -a shows all files including ones that are hidden, l is added showing a more informative view of your files.
regular ls command
command with added argument “ls -al”
As you can see, next to our “quickmath.py” file there are r’s and w’s. R stands for reading permission and W stands for writing. Other files such as vim also have X’s. This means that the file is executable.
To change this we use the chmod command. chmod allows us to change the mode of a given file. In this case we are adding executability to our quickmath python file.
In doing so, we have now made the file executable.
if we now rerun the file we should be able to see what we expected as the output.
success!!
Because the text editing in the actual console is not the greatest I went ahead and installed a package that would help with this. I tried to install vim through the cloud shell, but I needed access to sudo and I dont know what the password is. Instead, I took advantage of pip and installed the package pyvim which is very similar. Pyvim is a perfect text editor to make it easier to edit text files in terminal. Once installed, the command “pyvim” opens up the application.
Vim and its clones such as this do take a little bit of time to master as there are many many commands to be learned. After learning some of the commands though, the text editor does help a lot for development in the shell.