33
Learn Command Line
This is a cheat-sheet to go along with the stream I did on Scrimba YouTube channel about command line.
pwd
ls
echo 'hello Scrimba!'
# create
mkdir cmd-session
cd cmd-session
touch script.sh
mkdir sub-folder
# read
ls sub-folder
cat script.sh
# move/update
mv script.sh sub-folder/script.sh
mv script.sh new-name-new-file.sh
# delete
rm script.sh
rm -rf sub-folder
Create a script.sh
, example:
# touch script.sh, open it and write something like:
echo "hello, running script!"
echo "where am i?"
pwd
echo "ok, let's go somewhere else!"
cd /code
pwd
echo "that's better"
To execute a script:
./script.sh
### oh no, permission denied! what now?
# see permissions
ls -l
# they are repeated, 3 times, for user (owner of the file), group of users, everyone else.
# -rwx - read, write, execute
# to change permissions
chmod u+x ./script.sh
alias script='~/script.sh'
# is this an alias?
type script
node --help # -- is how you indicate a flag, -h is a shorthand, so node -h is the same.
For linux's own utilities, --help wouldn't work, so they have man
manual command.
man ls
For a more visually pleasant man
pages:
https://explainshell.com/
grep 'echo' ./script.sh
grep '<body>' ./
# grep: ./: Is a directory error, so you need to add recursive flag to search through directories
grep -r '<body>' ./
33