|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Unix FAQ Menu |
Question: I'm new to Linux and need some basic commands. I am lost how to list a directory, delete or rename a files, and search for strings and files. Apparently I've got a Shell. What is a shell ? Sorry this is really basic but I don't know where to start.. Answer:Well the short answer to your question is that ls lists a directory, rm deletes and mv renames files. grep searches for strings in files, and find searches for files. A Shell is Unix jargon for a command line interpreter - simply a program you enter commands into and it does something useful with them, well hopefully. Might by worth mentioning that there are two main flavours of shell - "Bourne" and "C" shells, at some point you may need to find out which you have, but at the moment its not that important to you. Below are some basic Unix commands you'll find useful, these are intended for both beginners & intermediate users, in alphabetical order;
What no feedback ?One quirk of many Unix commands that newcomers find disturbing it they don't report anything if the command succeeds. This is probably most perturbing with command like rm and rmdir which delete files and directories; shell% touch somefile shell% ls -l somefile -rw------- 1 andrew mercury 0 Jun 11 16:35 somefileNotice how the commands touch and rm reported nothing - they worked ok However, If you try to delete the same file again... shell% rm somefile somefile: No such file or directory shell% The behaviour seems a little odd if you're used to verbose operating
systems like Windows or VMS, but this is all part of the Unix philosophy
- why report anything when's there's nothing to say? Getting Help; The manual and the 'man' command.There's no help command for Unix, well if there is your site has made some special effort to provide it. The nearest thing is the man command - manual page. Say we wanted more information about the 'mkdir' command. shell% man mkdir The synopsis shows how to use the command and any options it may have. The square brackets '[]' indicate that that parameter is optional. In this case mkdir has the options -m and -p. -m requires a mode argument. The parameter dir (name of directory) is compulsory. The '...' denotes that there can be more 'dir' arguments - you can create multiple directories with one command. Manual page sectionsNote the top line of the above manual page - mkdir(1). You'll likely witness this a lot as you learn more about Unix. The number in brackets is the section number in the manual. The entry above came from section 1 - User Commands. You may come across references like "see lpc(8) for more information".
This simply is referring you to the entry for lpc (line printer control)
in section 8 of the manual. shell% man -s 2 mkdir
System Calls mkdir(2)
NAME
mkdir - make a directory
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
int mkdir(const char *path, mode_t mode);
DESCRIPTION
.............
Now you can see there is another manual page entry for mkdir, this time in section #2 - System Calls. This section is primarily aimed at programmers, we shown it here simply to demonstrate that the same name can exist in different sections. If you use the man command and see something completely unexpected check the man page section at top of the page. Keyword searches / Finding a commandBefore finishing up with the 'man' command one last useful feature is worth a mention - keyword searches. By using the '-k' option on the 'man' command you can find all the commands with that word in their description field. This can be quite useful when you don't know the name of a command; shell% man -k mkdir sun (bash) % man -k mkdir If you're only looking for commands you can ignore any pages that are not in Section 1 - User Commands. Later on you might also be interested in section 8 - Maintenance Commands
Tips:To search for a string (e.g "xyx") in all the files in the
current directory, try;
FeedbackI hope you found this FAQ to be of some use. It would be most helpful if you
could rate it below. All fields are optional... |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||