1. Explain the difference between the /etc/profile and the ~/.bash_profile file.
ID: 3854836 • Letter: 1
Question
1. Explain the difference between the /etc/profile and the ~/.bash_profile file. Which one is executed first?
2. Edit your .bash_profile file as follows:
1. Welcome the user
2. Add your home directory to the path if it is not there
3. Set erase to the Backspace key using stty.
4. Type source .bash_profile. What is the function of the source command?
3. What is the default primary prompt?
1. Change the prompt to include the time of day and your home directory.
2. What is the default secondary prompt? What is its function?
4. What is the difference between a program and a process? What is a job?
5. What command brings a background job into the foreground?
6. How do you list all running jobs? All stopped jobs?
7. Make a directory called wildcards. Cd to that directory and type at the prompt:
touch ab abc a1 a2 a3 all a12 ba ba.1 ba.2 filex filey AbC ABC ABc3 abc
Write and test the command that will do the following:
a. List all files starting with a.
b. List all files ending in at least one digit.
c. List all files starting with a or A
d. List all files ending in a period, followed by a digit.
e. List files ending in x or y
f. List all files ending in a digit, an uppercase letter, or a lowercase letter.
8. What command would you use to do the following:
1. Redirect the output of the ls command to a file called lsfile?
2. Redirect and append the output of the date command to lsfile?
3. Redirect the output of the who command to lsfile? What happened?
9. Use the find command to find all files, starting from the parent directory, of type directory. Save the standard output in a file called found and any errors in a file called found.errs.
10. What is a positional parameter? Type at the command line:
set dogs cats birds fish
1. How do you list all of the positional parameters?
2. Which positional parameter is assigned birds?
3. How do you print the number of positional parameters?
4. How do you remove all the positional parameters from the shell’s memory?
11. What is an environment variable? What is the command used to list them? Create an environment variable called CITY and assign it the value of your hometown. How do you export it?
Explanation / Answer
1)These two profile files are used to set environmental variables.The difference is that these two files are executed by depend on the type of login.That means,in Linux we have Interactive login Shells and Non-Interactive login Shells.By using interactive shell user can interact while by using a non-Interactive shell an user cannot interact.The /etc/profile is executed only for interactive shells and the /etc/bashrc is executed for both shells. etc/profile file starts first and calls the /etc/bashrc directly.
3)In linux we can customize bash command prompt like color,information. Bash can be customized by changing bash PS1, PS2, PS3, PS4 variables.PS1 is a primary prompt variable. It holds u@h:w$ special bash characters and this is default structure of the bash prompt.PS2 variable is a secondary prompt and it is displayed when it waits for a user input like, passwords.
4) program:
Program is nothing but set of instructions to perform certain task or function where as the process is an operation that takes the given instructions and performs as per the code and also called as execution.Process is dependent of program.
5)fg %number. Here number is job number.
6) By using ps aux | less we cann see all running jobs.
7) Ans: f) List all files ending in a digit,uppercase letter or a lower case letter.
8) 1) ls -lrt >> lsfile.
2) date > lsfile
3) who > lsfile
11) Environment variables are used to set values dynamically whhich affects the way of running processes.
We can create enviroonment vcariables by using setenv. ex: setenv city vijayawada
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.