# LF - Exercises 7 ##### 1. Create aliases for: ###### a) a command with options only. `alias lsall="ls -a"` ![](https://i.imgur.com/dm38l7o.png) ###### b) a command with options and arguments. `alias svagrant="grep -i vagrant vagrant.sh"` ![](https://i.imgur.com/9onQW8u.png) ###### c) more than one command. `alias folcontent="ls ; pwd ; whoami"` ![](https://i.imgur.com/IQgeKaX.png) ##### 2. Write a command to list hard and symbolic links. → check at ls man pages `ls -l --color /usr/ | grep "\->"` ![](https://i.imgur.com/6zFF4wt.png) ##### 3. Execute below commands and explain what they do: ###### a) $ ps aux --sort=-pcpu,+pmem Report a snapshot of the current processes, `-pcpu` to achieve percentage cpu usage descending, for ascending, use ‘+pmem’ ![](https://i.imgur.com/CCZeCZY.png) ###### b) $ ps -e -o pid,ppid,command,etime The ps command enables you to check the status of active processes on a system `-e` displays information about all the processes being executed on the system `-o` `pid,ppid,command,etime` are related to the process ID, the parent process's ID, the command that generated the process and etime could put the duration of time. ![](https://i.imgur.com/2kwsZKJ.png) ##### 4. How would you redirect and append stdout and stderr to file “filename”? `ls; echo "adding a new line"; kil -l; >>file.txt 2>&1` ![](https://i.imgur.com/0kx56Pf.png) ##### 5. What do below commands do? → Remember what is command in case you don’t know what a command does. ###### a) ls -1 *.txt | tee count.txt | wc -l The first part is getting all files with txt extention, after that it is redirectioning on a file called "count.txt", finally it is counting lines ![](https://i.imgur.com/dNEFzf2.png) ###### b) cat *.txt | sort | uniq > listFile The first part is showing txt files content, so all of the lines are sorted, with `uniq` command repeated lines are removed, this result are redirectioned to "listFile" file ![](https://i.imgur.com/KEQ6ctG.png) ##### 6. What happens if you run > filename command?