4. Alias I 2. alias hy issue


#1

I have been struggling with this exercise for some time now, but am still unable to progress to part 3.

Thanks in advance....


#2

Give us a couple screenshots of your whole web browser so that we can see what you see.


#3

@lisuda,
The Course started with.....

Each time we launch the terminal application, it creates a =new= session.
The session immediately loads settings and preferences
that make up the command line environment.

We can configure the environment to support the commands and programs we create.
This enables us to
customize greetings
and
customize command aliases,
and
create variables
to share across commands and programs.

You can reference the filesystem for this lesson here.
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

===============================================

You created a file in nano called ~/.bash_profile in your /home directory
( the =home directory= can be identified by using ~ )
and added a greeting. How does this work?
$ nano ~/.bash_profile

~/.bash_profile is the name of file used to store environment settings.
It is commonly called the "bash profile".

When a session starts,
it will load the contents of the bash profile before executing commands.
:black_medium_square:The ~ represents the user's home directory.
:black_medium_square:The . indicates a hidden file.
:black_medium_square:The name ~/.bash_profile is important,
since this is how the command line recognizes the bash profile.

  • 1.The command nano ~/.bash_profile opens up ~/.bash_profile in nano.
  • 2.The text echo "Welcome, Jane Doe" creates a greeting in the bash profile, which is saved. It tells the command line to echo the string "Welcome, Jane Doe" when a terminal session begins.
  • 3.The command source ~/.bash_profile
    activates the changes in ~/.bash_profile for the current session.
    Instead of closing the terminal and needing to start a new session,
    source makes the changes available right away in the session we are in.

===============================================

  • 1.Now that we know what bash profile is, let's continue configuring the environment by adding command aliases.
    Open ~/.bash_profile in nano.

  • 2.. In ~/.bash_profile, beneath the greeting you created, type
    alias pd="pwd"

What happens when you store this alias in ~/.bash_profile?
alias pd="pwd"

The alias command allows you to create keyboard shortcuts, or aliases, for commonly used commands.
1.Here alias pd="pwd" creates the alias pd for the pwd command,
which is then saved in the bash profile.
Each time you enter pd, the output will be the same as the pwd command.
2.The command source ~/.bash_profile
makes the alias pd available in the current session.

Each time we open up the terminal, we can use the pd alias.

  • 1.. Let's practice aliases some more. Open ~/.bash_profile in nano.

  • 2.. In the bash profile, beneath the previous alias, add
    alias hy="history"

Save the file. Press Enter to write the filename.

  • 3.. Add another alias
    alias ll="ls -la"

Save the file. Press Enter to write the filename. Exit nano
Clear the terminal window.
http://stackoverflow.com/questions/5367068/clear-the-ubuntu-bash-screen-for-real

  • 4..In the command line, use source to activate the changes to the bash profile for the current session.

  • 5..Let's try out the aliases. In the command line, type
    hy

  • 6..Now type
    ll

---------------------------------------------------------------------------------

What happens when you store the following aliases in ~/.bash_profile?
alias hy="history"
hy is set as alias for the history command in the bash profile.
The alias is then made available in the current session through source.
_source ~/.bash_profile
By typing hy,
the command line outputs a history of commands that were entered in the current session.

alias ll="ls -la"
ll is set as an alias for the command ls -la
and made available in the current session through source ~/.bash_profile.
By typing ll, the command line now outputs
all contents and directories in long format, including all hidden files.

=========================================

  • 1.
    Now that you are familiar with configuring greetings and aliases, let's move on to setting environment variables.
    Open ~/.bash_profile in nano.

  • 2.
    In the bash profile, beneath the aliases, on a new line, type
    export USER="Jane Doe"
    Feel free to use your own name.
    Save the file.
    Press Enter to write the filename.
    Exit nano.
    Finally, clear the terminal.

  • 3.In the command line, use the source ~/.bash_profile command,
    to activate the changes in the bash profile for the current session.
    http://stackoverflow.com/questions/4608187/how-to-reload-bash-profile-from-the-command-line
    source ~/.bash_profile

  • 4.. Type
    echo $USER
    This should return the value of the variable that you set.


#4

Thanks guys, I changed my browser and that seemed to do the trick. I am stuck at 84 percent....