Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It is used as a command at the command prompt. The command prompt is displayed by the shell (usually bash) in a terminal. Which desktop are you using? Could be Gnome, KDE, Unity ... Details of how to start a terminal depend on the desktop.
All I know is that I have installed a VMware player and the word Fedora is at the top. I go to applications/system tools/terminal and a terminal is open.
In this script, the only command line is the very first line, all the rest are script? is this correct?
A script is, generally, a file containing commands. For a bash script, anything following a # is a comment (unless the # is buried inside something like a string).
Thus, in the journal script, there are 3 comments:
Code:
#!/bin/bash
# journal: add journal entries to the file
# $HOME/journal-file
The last two are simply comments to help the programmer. The first is special; it's a shebang. A shebang allows you to run a script as if it were a command. A #!/bin/bash shebang says "start /bin/bash and give it this file as input to execute". The file is a script and it contains bash commands, the same commands as you could type in at a command prompt.
All I know is that I have installed a VMware player and the word Fedora is at the top. I go to applications/system tools/terminal and a terminal is open.
Good; so you have a terminal and hopefully the terminal is displaying a command prompt. The prompt is configurable so could be anything (what's yours?) but conventionally ends with a $. You can type a command and press Enter and the command will be run (executed). For example the ls command lists files in your current directory and the date command tells you the time and date. The chmod (change mode) command can be used to set the permissions on files and directories.
A script is, generally, a file containing commands. For a bash script, anything following a # is a comment (unless the # is buried inside something like a string).
Thus, in the journal script, there are 3 comments:
Code:
#!/bin/bash
# journal: add journal entries to the file
# $HOME/journal-file
The last two are simply comments to help the programmer. The first is special; it's a shebang. A shebang allows you to run a script as if it were a command. A #!/bin/bash shebang says "start /bin/bash and give it this file as input to execute". The file is a script and it contains bash commands, the same commands as you could type in at a command prompt.
Good; so you have a terminal and hopefully the terminal is displaying a command prompt. The prompt is configurable so could be anything (what's yours?) but conventionally ends with a $. You can type a command and press Enter and the command will be run (executed). For example the ls command lists files in your current directory and the date command tells you the time and date. The chmod (change mode) command can be used to set the permissions on files and directories.
No. The command prompt ends with a $ but it is not part of the command. The shell uses $ as a "dereference operator" meaning if you have a variable called foo, $foo means "the value of variable foo". It is possible to create commands that begin with $ but they would be inconvenient to use because of the shell's use of $
The ~ part of it shows that your current directory is your home directory. If you cd (change directory) to something else it will change. You could try cd /tmp to see what I mean. Plain cd will get you back to your home directory.
Last edited by catkin; 07-23-2011 at 03:34 AM.
Reason: Spelling: Plaid to Plain
The ~ part of it shows that your current directory is your home directory. If you cd (change directory) to something else it will change. You could try cd /tmp to see what I mean. Plain cd will get you back to your home directory.
I tried cd/tmp and got this, bash: cd/tmp: no such file or directory
As Nylex implied, his link is like the sequel to the beginner's guide, but it's not super difficult, just more techniques.
All 3 links are worth bookmarking imho.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.