- Create a file - Write content inside the file - exit
- $nano hello.txt // create file named "hello.txt"
- write down "Hello, I am nano" in the file
- Ctrl + o // save a file
- Ctrl + x // exit the nano program
- Ctrl + g // open a help menu
- clear // clear the terminal window, moving the command prompt to the top of the screen
- ~/.bash_profile
- ~/.bash_profile is the name of file used to store environment settings. (usually called bash profile)
- $nano ~./bash_profile // opens up ~/.bash_profile in nano (~ : represents the user's home directory . : indicates the hidden file )
- Type the echo "Welcome, Jane Doe"
- Ctrl + o , Ctrl + x , clear
- $source ~/.bash_profile // activates the changes in ~/.bash_profile for the current session. (source makes the changes available right away)
- Alias command
- in nano ~/.bash_profile, write down alias pd="pwd" (alias command allows you to create keyboard shortcuts for commonly used commands)
- Use source ~/.bash_profile to activate the changes to the bash profile for the current session.
- Once you type pd in terminal, the output is same as pwd command
- Assign Variable - export USER="YOUR NAME"
- In nano, ~/.bash_profile, write down export USER="your name" (USER is variable, "your name" is a value, export makes the variable to be available to all child sessions initiated from the session you are in)
- echo $USER -> return the value of the variable
- Change default command prompt from $ to >>
- In nano, ~/.bash_profile, add new line with export PS1=">> "
- and exit after changing it, use a source command
- after using source command, you can see the change of command prompt
- env | grep PATH
- env command stands for environment, and return the list of environment variables for the current user. (including PATH, PWD, PS1 and HOME)
- If grep is used with PATH, only path will be printed.
Reference - https://www.codecademy.com/learn
No comments:
Post a Comment