More powerful than the spiky blue shell
Follow these steps to set up your own repository:
-
Fork this repository on GitHub to create your own version of this repo on your GitHub account, which should also be named
Core-Unix-Utilities
-
Visit your fork and clone that repository onto your computer:
git clone https://github.com/<your-username>/Core-Unix-Utilities.git
-
Push your commits and link the local repo to your remote GitHub repo:
git push -u origin master
-
When you've completed a challenge and want to share it for code review, commit your work and push it to your own remote repo with:
git push
-
Add this GitHub repository as a remote to the local one on your computer:
git remote add core https://github.com/Product-College-Labs/Core-Unix-Utilities.git
-
When you want to access new course materials, just pull from the origin remote repo:
git pull core master
Challenges within each section are meant to be solved in order.
- Print the path of your working directory
pwd
- List the files in your working directory
ls
ls -a
- List the files with a particular extension, like
.txt
ls *.txt
- List the files in a subdirectory, like
project
ls -l $(find /project -type f )
ls directory
- Navigate to a subdirectory, like
project
cd /project
- Navigate to the parent directory of your working directory
cd ..
- Navigate to a nested subdirectory, like
path/to/project
cd path/to/project
- Navigate to your home directory
cd /home
cd ~
- Navigate back to the previous directory
cd -
cd ../../../
control a and control e to jump from begging and end of line control k and y cut and yank
-
Print a sentence, like
Hello world
echo hi
-
Print a variable value, like
$USER
or$PATH
echo "$USER"
-
Set a variable
NAME
equal to your first name, then print its valueNAME=Elmer
echo "$NAME"
-
Set a variable
FULL_NAME
equal to your full name, then print its valueFULL_NAME=ELMER_ASTUDILLO
echo "$FULL_NAME"
-
Print all environment variables (names and values)
printenv
-
Make an alias named
hello
that printsHello world
alias hello='echo hello world'
-
Make an alias named
gocode
that navigates to your code directoryalias hello='echo cd /Users/elmerastudillo/desktop/Core-Unix-Utilities'
-
Print all aliases (names and values)
alias
- Print what options a command accepts, like
bash
orpython
--help
- Read the manual for a command, like
echo
orls
man
- Print the file path to a command, like
bash
orpython
which
-
Navigate to the directory
Animals
-
Print the contents of the file
Cats.txt
cat Cats.txt
- Print the contents of both files
Cats.txt
andDogs.txt
more Cats.txt
- Count the words in the file
Cats.txt
wc -w cats.txt
wc -l cats.txt
wc -c cats.txt
- Count the words in all files with the extension
.txt
wc *.txt
- Copy the file
Dogs.txt
to a new fileBabyDogs.txt
cp Dogs.txt BabyDogs.txt
- Rename the file
BabyDogs.txt
toPuppies.txt
mv
- Make a new directory named
Shelter
insideAnimals
- Move the file
Puppies.txt
into the directoryShelter
mv Puppies.txt Shelter/
- Copy the file
Cats.txt
toKittens.txt
insideShelter
cat Cats.txt >> Folder
- List the files within the directory
Shelter
ls directory/
- Count the words in all
.txt
files insideShelter
wc Shelter/*.txt
- Try to remove the directory
Shelter
(this should fail)
mdir
- Remove all
.txt
files insideShelter
rm Shelter/*.txt
- Remove the directory
Shelter
(this should succeed)
rmdir Shelter/
- Now cry because you just deleted those poor tiny animals
rm -r /
rm -r ~
- Print out your user name
- List the permissions (and metadata) of all
.txt
files - Give all users write permission on the file
Cats.txt
- List the permissions (and metadata) of the file
Cats.txt
- Change the owner of the file
Cats.txt
to another user - Now list the permissions (and owner) of the file
Cats.txt
- Try to change the owner of the file
Cats.txt
back to yourself - Invoke the super-user to make the previous command succeed
- List the permissions (and owner) of the file
Cats.txt
again