UNIX Problems

Practice Problems (GEN220 week #1)

  1. Go to the top level of the file system, find subdirectories under it; go to your home directory; confirm with “pwd”
  2. Find the values of your environmental variables $HOME, $USER, $PATH
  3. Create an empty file “hello.txt” in your home directory, create a “temp” directory, move “hello.txt” to “temp”, check your command history, recreate the file under home directory using repeating command
  4. Change directory to “/bin”, without leaving this directory, perform the following operations:
    1. Create a directory called “Tears” inside your home directory
    2. Create a directory called “123” inside “/tmp”
    3.  Create another directory (“XYZ”) inside “123”
    4.  Move the nested directory “123/XYZ” inside the “Tears” directory
    5. Confirm this move happened successfully
    6. Now move just the “XYZ” directory to “/tmp”
    7.  Create two empty files “bar.fa” and “foo.fa” under “XYZ”, then copy directory “XYZ” along with these two files to “123” using one command
    8. Finally, remove all temporary directories and files that you just created
  5. Work on file /home/rliu/GEN220/example_map.txt, and answer the following questions:
    • What is the size of this file (in MB)?
    • How many lines are in this file? (hint: use “wc” with an option)
    • How many sequences contain motif “TTTTT”? How many contains “CGGA” or “CGGAA”?
    • How many sequences are mapped to each chromosome?
  6. Use nano editor to create a file “readme.txt” in your home directory. Put your name, your birthday, your favorite color in this file. The format should be like this:
    Name=John Doe
    Birth_date=1/1/1990
    Favorite_color=blue
  7. Create a shell script “today.sh” so that each time it is run, it will generate the following output (variables are in brackets and their values depend on you and your machine):
    my username is ;
    feels good today;
    I am working on machine ;
    it has the best kernel in the world: ;

    (hint: use $USER, and commands “hostname”, “uname -rs” to obtain the values that you need)

  8. Create a “bin” directory in your home directory, put “today.sh” from question #7 under “~/bin”, modify your .bashrc or .profile file so that “~/bin” is included in $PATH, execute the script from your home directory by just typing “today.sh”.

Leave a Reply