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.
I am trying to learn coding in C in a Linux environment. Now the problem is that I have never used Linux before.
Now in my book it stated I needed to see if the file was actually stored in a certain location using the following command and parameters.
Code:
-ls -l [./filename]
Now I looked this up using google and -ls seems to be the same to me as 'dir' in the Windows system and -l is the parameter deciding what information is shown.
What I do not understand is why I needed to write './' in front of the file name. I thought the -ls command lists only the files in the current directory and that './' has the same meaning (search in current directory).
Next to that, am I right in saying that by attaching the files name to '-ls -l' I make it only display the info for that particular file?
whilst it's just "ls" as a command, no - before it, you are right, there's no need to use ./ here. And yes, as per the documentation you have available to you already, putting a file name, or pattern, as a parameter, only matching files will be shown.
whilst it's just "ls" as a command, no - before it, you are right, there's no need to use ./ here. And yes, as per the documentation you have available to you already, putting a file name, or pattern, as a parameter, only matching files will be shown.
Sorry for the '-' in front of the ls. Would the following command then result in the same or does the 'ls' command need to be send with it in every case?
ls is the command name. -l is just one of many options you can add to it to determine what information is displayed and how. In this case it stands for the "long" format. man ls will give you the documentation with the rest.
. (single dot) is just the relative path character for the current directory (just as .. means the containing directory), so ./filename is simply the relative path to the file, meaning of course "filename in this directory". Generally you do not need to use it with simple command arguments such as with ls, as the Present Working Directory is usually considered the default by most programs. So ls -l filename will work just fine. You only really need to add it when a full or relative path is expected, the most common case being launching scripts or executables when the current directory isn't in your PATH environment setting, or when the program you are feeding it to doesn't know to look in the PWD for some reason.
I recommend linuxcommand.org for a good primer on how to navigate around the shell.
Sorry for the '-' in front of the ls. Would the following command then result in the same or does the 'ls' command need to be send with it in every case?
Code:
-l [./filename]
ls is a command analagous to the windows dir command -l is an argument that makes the command more precise
In this case what you want is ls -l
There are many more arguments you can pass to the ls command
To learn about those, try the following
Code:
ls --help
man ls
The same type of research will apply to any linux command: use man command or command --help
FWIW, my favorite ways to get directory listings that are sorted, displayed in columns, and detailed are
Code:
ls -laSh
ls -laS
And one last tip: in linux every command and every filename is case-sensitive. If you aren't precise with case in commands and filenames, you will get unexpected results.
Last edited by snorky; 12-28-2010 at 02:08 PM.
Reason: clarify even more
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.