User Tools

Site Tools


user:adahmane:portfolio:unixnotes

To change the prompt…

PS1='C:\\\w> '

That will set your prompt to:

C:\~>

as opposed to

lab46:~$

which is set up by having the following…

PS1='\h:\w\$ '

CTRL+r will allow us to search through previously used commands.

“history” lists out our previous entries in the terminal.


MultiTasking!!!??!?!?

Linux is a Multi User Multi Tasking System… That's how we can all log into Lab46 and work at the same time.

Background vs. Foreground

Stopped vs. Running

Key Press: Result:
CTRL+c SIGINT
CTRL+d EOF
CTRL+z SIGUSP/SIGSTOP

Running a program with an ampersand “&” will try to run it in the background. In Unix, a server/service is called a “Daemon”.

“sleep” is pretty nifty… This allows us to run a command later (if we choose to do so.)

(sleep 30; ls)&

This will wait 30 seconds, run ls, and stay in the background. The ls will appear in our terminal.

A running program is called a process.

ps will show us process statuses on our current terminal.

kill -l shows us the 64 different ways to kill a process

ps shows us our running processes. ps aux shows all of the running processes on the system.

If we say “kill -1 29606”

That will kill the process with the ID of 29606 (found when you use ps) by using the SIGHUP method to kill it. That's a hangup. It's more “friendly.” kill -9 is the most abrasive way to kill things. kill -9 -1 is bad. Don't do that. It kills everything that is “kill-able.”


Arrays!

Instead of having a variable that must be typed and increased EVERY SINGLE TIME, we can use an array.

Example…

read battle1exp read battle2exp read battle3exp

We can do this…

for 1);do

      echo -n "Enter score: "
      read score
      battleexp[$i]=$score

done total=0 for2);do

      let total=$total+${battleexp[$i]}

done echo “Your total score is $total”


Scripts vs. Programs

Interpreted Code - HTML, bash, vbscript, PHP, Python, javascript, etc…

Compiled Code - C, C++, Pascal, Fortran, etc…

1) , 2)
i=0;i<12;i=i+1
user/adahmane/portfolio/unixnotes.txt · Last modified: 2013/12/14 11:25 by adahmane