Created
February 20, 2015 17:56
-
-
Save jordanpoulton/f4cb14e9361a425d2bb9 to your computer and use it in GitHub Desktop.
Command_Line_Questions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Joe knowles | |
1. Make directory structures: temp/my/files and temp/other/file | |
2. In temp/my/files make a file chrome.txt which contains a list of the last 5 environment variables | |
3. Navigate to temp/my/files then push that directory while navigating to temp/other/file | |
4. Put the number of history entries into a file called my_history.count | |
5. 'pop' back to the temp/my/files | |
6. Install "cowsay" with this command - $ sudo gem install cowsay | |
7. Use cowsay to tell you how many Chrome processes are running | |
8. Save a file called farm.txt with two cowsay animals trying to be entertaining | |
9. Print farm.txt to the screen | |
10. List all environment variables starting with an underscore | |
11. Find the value of variable "_system_name" | |
12. Part with an animal by having them say "Goodbye!" | |
Ilya | |
1. Make the bash wait 3 seconds before returning the command prompt. | |
2. In your home directory, create two empty text files, append a line of text to each of them, and then (in one line of code) put the contents of the two files into a new file. | |
3. Create a new text file and add to it a list of your favourite music bands (if you have any). Then, in one line of code, sort the bands alphabetically and store the result in yet another new file. | |
4. Execute you 5th most recent command. | |
5. Display the last 10 lines of ~/.bash_history file. | |
6. Find out how many bash commands have the word ‘blue’ in their manual page header. | |
7. Count the number of env variables whose value ends with the last letter of your last name. | |
8. Purely in the terminal (without referring to any files), input 4 lines of text and immediately sort them alphabetically. | |
Dan Blakeman | |
1. Create an environment variable called "THIS_WONT_LAST_LONG", and set it to equal "True". | |
2. Check it worked, by running 'env'. Then see if you can remove it, without closing the terminal window. | |
3. Let's play russian roulette! Type "sleep 100 &" this will create a background process which is counting down from 100. See if you can research how to kill the process before it's finished. | |
4. Type "Sleep 1000", this will create the same process in the foreground (Meaning it will wait 1000 seconds before showing you the '$' prompt again). See if you can research a way to move this process to the background, without killing it. | |
5.Without editing any files, set a (none environment) variable called '$HELLO' to equal "Hello Maker, How's it going?". (This will not exist after you close the terminal window - that's ok) | |
6.echo $HELLO and ensure it returns the above string. Then unset the variable, and check echo-ing no longer works. | |
7.Create a ruby file on your desktop called 'where_am_i.rb', inside it enter the text 'puts "At your Mac! (or linux!)"'. | |
8.Add a shebang and adjust it's permissions so you can execute this file without calling 'ruby' before its name. Test it works. | |
9.That ruby file name was kinda long. I'd rather not keep typing it. Set a variable called 'FIND_LOCATION' to equal the command needed to execute the file. | |
10.Ensure that calling $FIND_LOCATION in your terminal window results in 'At your Mac! (or linux!)'. | |
11.Add the code that made the above command possible to your bash profile. Close your terminal, and open a new terminal window. Can you still call '$FIND_LOCATION' to find a useless witty comment? Does it work in every directory eg: can you call it from your home directory, and desktop to the same effect? Make sure it does! :) | |
12.Repeat steps 7-11, so that in the future, no matter which directory you are in, you can call $WHOS_A_WIZARD, and have a ruby file return to you: 'YOU'RE A WIZARD HARRY!!'. Find a way of testing it works, *without* having to restart the terminal/or open a new terminal window. (This will involve reloading your bash profile)... | |
**CONGRATULATIONS YOU ARE NOW A COMMAND LINE WIZARD** | |
Rob Bowers | |
1. Create a variable that would still open in a new shell LINETWO=below | |
2. Create a local variable $LINEONE=above | |
3. Using a single line of commands create a file newlines.txt with the contents of $LINEONE on the first line, a blank line on the third line and the contents of $LINETWO on the third line. | |
4. Ask the terminal which man pages are appropriate for the term 'ruby' , save this to a file called rubysuggestions.txt | |
5.Create a folder Structure on the Desktop test/level_one/level_two | |
6.Return the terminal to the home directory, from here list the permissions of the level_one folder you created using one line. | |
7.Create a file called goodbye.rb in level_one and insert the following text: puts "Goodbye!" | |
8.Using VI add the ruby shebang on the first line of the file | |
9.Complete the final action required to make this file run in the terminal and run it. | |
10. Navigate to the level_one folder and use the terminal command to open sublime at this directory location | |
11. Using the history command print on screen the 8th command you wrote before this one, using one line only | |
12. Push the current directory to pushd then change directory to the Desktop. Return to the previous directory with one command with no arguments. | |
JADE: | |
Questions | |
1. Using one command, create a directory practice-files/commands/ | |
2. Create a new environment variable TEMP_ENV=temporary. It should Only show up in this terminal | |
3. Create a new environment variable MAKERS_STUDENT=Having-fun so that it would show up in a new terminal. | |
4. List all env variables that start with M, sort them alphabetically and add them to a new file called env-m.txt | |
5.Make a list of all mp3 files from the home folder in a new file called music.txt in practice-files/commands | |
6. Append to music.txt the amount of mp3 files on your computer | |
7.Change persmissions on music.txt so that everyone can read it but only the owner can edit it. | |
8.Change persmissions on env-m.txt so that everyone can edit it | |
ICIAR | |
1. go to your home directory and create a file named lorem1 saved at the same time in a new folder named ichi_challenge. | |
2. add this text to the file lorem1 “Lorem ipsum dolor sit amet, consectetuer adipiscing elit.” | |
3. create another file named lorem2 and add the next three lines using echo | |
• Aliquam tincidunt mauris eu risus. | |
• Vestibulum auctor dapibus neque. | |
• Nunc dignissim risus id metus. | |
4. find the file that has the word “dolor” and the one that has more than one line and combine them in a new file named loremCombined | |
5. delete the second to last line and save it using vi | |
6. make a copy of the combined file and name it copy-loremCombined | |
7. check for files in home directory and subdirectores looking for files that has the word “risus” and print these files names in ichi-challenge/files/risusFiles | |
8. add to risusFiles the name of the variable with value x86_64 | |
GUS (the formatting/ordering is intentional): | |
1. Create folder tree temp/challenges/ on the Desktop using single command. | |
2. Create a copy of the instruction file called Challenge_sorted.txt with the right arrangement of the tasks. Place it in temp/challenges/ folder. | |
5. Retrieve the title page of google.com, find a line with string 'A HREF' and save it to /temp/google_link.txt | |
8. Search your documents directory (or any directory with a lot of files) for files that contain "r" AND "a" strings anywhere in the filename. Sort the resulting list by modification date and put in the file temp/regex_search_result.txt | |
6. Create a new file temp/combined.txt by combining contents from temp/challenges/Challenge_sorted.txt and temp/google_link.txt | |
3. Recursively set read, write and execute rights for the user and no rights to group and others for all newly created folders and files. Use numeric permissions only. | |
7. Print "Hello, World!" to the terminal using echo command (with the exclamation mark). | |
4. Set the environment variable MESSING_ABOUT to the last line from text file Challenge.txt with ALL white space removed. No text editors! | |
MARK: | |
1: Create a directory called ‘temp’ in your home directory and change into it. | |
2: Export a new variable called ‘DATE’ and give it today’s long date and time (i.e. Wednesday 18 February 2015 - 14:45) using the ‘date’ command (hint: you’ll need to use ‘+’ followed by the ‘%’ formats listed in the man page). | |
3: Create a directory called ‘bash’ in the current directory. | |
4: Count the number of times the WORD ‘bash’ appears in the bash manual. Output this number to a new file called ‘bash-count’ in the ‘bash’ directory (this may throw up an error about not being able to break lines, don’t worry if it does). | |
5: Using just one command, save the following text to a file named ‘today’ with the following three lines: | |
Today's date is: | |
DATE | |
Isn't it a nice day? | |
with the word ‘DATE’ replaced by today’s date using the variable you created in Q2. | |
6: List all the files in your home directory only, and display them in reverse alphabetical order | |
7: Using the ‘date’ command, display tomorrow’s date (long format in Q2 but without the time). | |
8: Count the number of files in your home directory (recursively) with a ‘0’ (zero) somewhere in their names. | |
9: Tricky bonus question: | |
Count the number of files in your home directory (recursively) with numbers (i.e. 0-9) somewhere in their names. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment