Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bash Primer?
#1

Can anyone point me in the right direction for a good bash primer? I like to use terminal (call me crazy, maybe?) because I don't have to worry about give the file management system escalated permissions and I really loathe using a mouse unless I have to. Coming from Windows I had most of my DOS commands down but still have trouble with syntax and switches etc..

Any help would be appreciated.

Reply
#2

first tip:- if you need help with a command type

 



Code:
man command




 

replace the word command with whatever you need help on, eg:

 



Code:
man top




 

second tip:- get used to using a text editor called vi, it's in nearly all linux distros out there and you'll need it to read the help files which are nearly always text based

 

third tip:- linux (unlike windows) is case sensitive so a command like this will work

 



Code:
top




 

whereas

 



Code:
Top




 

will most likely fail

Reply
#3

There's a pile of system scripts in /etc/init.d - it's worth sneaking a look at a few there and try to puzzle out what they're doing.

 

A number of things to point out before you start writing your own scripts:

<ol style="list-style-type: decimal">
[*]your scripts need to have EXECUTE permission on (chmod u+x myscript) in order to run


[*]your scripts need to be in a directory mentioned in your ${PATH} variable to run them by name alone. Your "bin" dir inside your own home directory is a common place to put them.


[*]use the "which" command to see if that script name (or command name) is already taken, eg: "which date" or "which mydate".


[*]Don't call your scripts "script" or "test". It's a common mistake, but they're reserved words.


[*]Some people like to append a file extension, such as ".sh" to their script names. Unlike windows, the actual filename isn't important, but don't forget to use its full name ("autoexec.sh", not just "autoexec")


[*]Minor point, but sometimes writing and saving (without quitting) in one window then running in another window means you can quickly compare code and results side-by-side.


[*]If you dislike vi, consider installing "nano" or "pico" as alternative editors


[*]If you already know all that stuff above... well, let's move onto lesson 2!


</ol>


 

Good luck!

Reply
#4

Oh, and one last bit: feel free to post examples of your non-working code in here. We can give you pointers as to why it doesn't work, as well as alternative ways of writing the same script.

 

(well, Hybrid can, because he's tha King Kodah here. I'm just a serf)

Reply
#5

Quote:(well, Hybrid can, because he's tha King Kodah here. I'm just a serf)
 

I am? That's news to me! :)

Reply
#6

A few resources that might be of interest with getting started with the Linux command line:

 

Free Software Magazine's introduction to the command line -- http://www.freesoftw...mand_line_intro

 

FOSSwire's Command Line Cheat Sheet* -- http://fosswire.com/...nd-cheat-sheet/

 

I also put together a trio of videos which explain some of the fundamentals of command line. It's focused at Mac users, but there is a lot of commonality between the command line environments on Mac OS X and Linux, so I think they might be valuable to you too. They have, for the moment, disappeared from the internet, because the podcast for which they were made has undergone some changes, but I'm going to try and get them back online and post a link here.

 

* I should mention that, while I didn't make this particular cheat sheet, FOSSwire is a site that I co-founded and make a bit of money from.

Reply
#7

This is a useful website too:

 

http://linuxcommand.org/

Reply
#8

Here is the first video to which I was referring earlier. You might find it helpful with some of the fundamentals, but it might be a bit repetitive with some of the crossover between the DOS CLI. You might want to skip some Mac-specific stuff and introduction and go straight to 03:30 minutes in.

 

http://www.youtube.com/watch?v=yIY3iPDVUBg

 

I am uploading the others and will update the post here with those too, in case they might be helpful. There are some things that are Mac-specific (like the reference to the Library directory), but the majority of the stuff shown here is exactly the same on Linux.

Reply
#9




<div><iframe width="480" height="270" src="https://www.youtube.com/embed/i16cQTULEjM?feature=oembed" frameborder="0" allowfullscreen="true"></iframe></div>
 




<div><iframe width="480" height="270" src="https://www.youtube.com/embed/KRs-rEx-EJA?feature=oembed" frameborder="0" allowfullscreen="true"></iframe></div>
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)