






السمعة:
هنا هيكون شرح بسيط لكل شي محتاج تعرفه عشان تبدأ صح مع أوامر اللينكس و تقدر تستفاد بقوه التيرمنال

Basic Command Syntax
To execute a command, the first step is to type the name of the command
كود:
sysadmin@SH3LL:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
ls
في التيرمنال من غير أي options
أو arguments
.By itself, the
Many commands can be used by themselves with no further input. Some commands require additional input to run correctly. This additional input comes in two forms: options and arguments
Commands typically follow a simple pattern of syntax
ls
command lists files and directories contained in the current working directoryMany commands can be used by themselves with no further input. Some commands require additional input to run correctly. This additional input comes in two forms: options and arguments
Commands typically follow a simple pattern of syntax
كود:
command [options…] [arguments…]
When typing a command that is to be executed, the first step is to type the name of the command. The name of the command is often based on what the command does or what the developer who created the command thinks will best describe the command’s function
For example, the
For example, the
ls
command displays a listing of information about files. Associating the name of the command with something mnemonic for what it does may help you to remember commands more easilyKeep in mind that every part of the command is normally case-sensitive, soLS
is incorrect and will fail, butls
is correct and will succeed.
ودي ملحوظه مهمه جدا خصوصا في بدايتك مع التيرمنال … لأن كتير بيطلعلك ايرورز لما تكتب الامر وبتكون المشكلة انك اتلغبط في الحروف case-sensitive
Specifying Arguments
command [options] [arguments]
An argument can be used to specify something for the command to act upon. Following a command, any desired arguments are allowed or are required depending on the command. For example, the
touch
command is used to create empty files or update the timestamp of existing files. It requires at least one argument to specify the file name to act upon
كود:
touch FILE...
كود:
sysadmin@SH3LL:~$ touch newfile
The
ls
command, on the other hand, allows for a path and/or file name to be specified as an argument, but it’s not required
كود:
ls [FILE]...
إذا لاحظنا وضعfile
مبين مثالtouch
و مثالls
؛ في مثال touch من غير ال[]
لأنه required بعكس في مثال ls داخل ال[]
لانه يعتبر optional ممكن تستخدمه من غيره
لصوره اوضح يمكنك الأشاره إلي Man Pages Synopsis
An example of a scenario where an argument is allowed but not required is the use of the
ls
command. If the ls
command is used without an argument, it will list the contents of the current directory
كود:
sysadmin@SH3LL:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
If the
ls
command is given the name of a directory as an argument, it will list the contents of that directory. In the following example, the /etc/ppp
directory is used as an argument; the resulting output is a list of files contained in the /etc/ppp
directory
كود:
sysadmin@SH3LL:~$ ls /etc/ppp
ip-down.d ip-up.d
The
ls
command also accepts multiple arguments. To list the contents of both the /etc/ppp
and /etc/ssh
directories, pass them both as arguments
كود:
sysadmin@SH3LL:~$ ls /etc/ppp /etc/ssh
/etc/ppp:
ip-down.d ip-up.d
/etc/ssh:
moduli ssh_host_ecdsa_key ssh_host_rsa_key
ssh_config ssh_host_ecdsa_key.pub ssh_host_rsa_key.pub
ssh_host_dsa_key ssh_host_ed25519_key ssh_import_id
ssh_host_dsa_key.pub ssh_host_ed25519_key.pub sshd_config
Some commands, like the
cp
command (copy file) and the mv
command (move file), always require at least two arguments: a source file and a destination file
كود:
cp SOURCE... DESTINATION
هنا الثلاث نقاط تدل علي أمكانية التكرار
لصورة أوضح يمكنك الإشارة إلي Man Pages Synopsis
ملوظة مهمه جدا : في بعض الأحيان قد نحتاج وضع ال text arguments داخل""
Options
command [options] [arguments]
Options can be used with commands to expand or modify the way a command behaves. If it is necessary to add options, they can be specified after the command name. Short options are specified with a hyphen
-
followed by a single character. Short options are how options were traditionally specifiedملحوظة : هناك ثلاث طرق رئيسية لاستخدام ال options :
the BSD way : with no hyphen —> service
short way : with only one hyphen followed by one character —> ls
long way : with two hyphen followed by the option name —> ls
In most cases, options can be used in conjunction with other options. They can be given as separate options like
Multiple single options can be either given as separate options like
status
example.serviceshort way : with only one hyphen followed by one character —> ls
-a
long way : with two hyphen followed by the option name —> ls
--all
In most cases, options can be used in conjunction with other options. They can be given as separate options like
-l -r
or combined like -lr
. The combination of these two options would result in a long listing output in reverse alphabetical orderMultiple single options can be either given as separate options like
-a -l -r
or combined like -alr
. The output of all of these examples would be the same
كود:
ls -l -a -r
ls -rla
ls -a -lr
Generally, short options can be combined with other short options in any order. The exception to this is when an option requires an argument
For example, the
If you are using multiple options that require arguments, don’t combine them. For example, the
Commands that support long options will often also support arguments that may be specified with or without an equal symbol (the output of both commands is the same)
For example, the
-w
option to the ls
command specifies the width of the output desired and therefore requires an argument. If combined with other options, the -w
option can be specified last, followed by its argument and still be valid, as in ls -rtw 40
, which specifies an output width of 40 characters. Otherwise, the -w
option cannot be combined with other options and must be given separatelyIf you are using multiple options that require arguments, don’t combine them. For example, the
-T
option, which specifies tab size, also requires an argument. In order to accommodate both arguments, each option is given separatelyCommands that support long options will often also support arguments that may be specified with or without an equal symbol (the output of both commands is the same)
كود:
ls --sort time
ls --sort=time
كود:
sysadmin@SH3LL:~$ ls --sort=time
Desktop Documents Downloads Music Pictures Public Templates Videos
A special option exists, the lone double hyphen--
option, which can be used to indicate the end of all options for the command. This can be useful in some circumstances where it is unclear whether some text that follows the options should be interpreted as an additional option or as an argument to the commandودي معلومة مهمه جدا … لأن في ناس كتير بتستخدم التيرمنال واوامر اللينكس بشكل يومي وميعرفهاش![]()
![]()
For example, if the
The command tries to interpret
touch
command tries to create a file called --badname
The command tries to interpret
--badname
as an option instead of an argument. However, if the lone double hyphen --
option is placed before the file name, indicating that there are no more options, then the file name can successfully be interpreted as an argument
Command Information
The
type
command displays information about a command type. For example, if you entered type ls
at the command prompt, it will return that the ls
command is actually an alias for the ls --color=auto
commandيمكن استخدام option-a
مع الأمرtype
لمعرفة مكان الأوامر.
This command is helpful for getting information about commands and where they reside on the system. For internal commands, like the
For external commands like the
If a command does not behave as expected or if a command is not accessible, that should be, it can be beneficial to know where the shell is finding the command
The
Note
The
pwd
command, the type
command will identify them as shell builtinsFor external commands like the
ip
command, the type
command will return the location of the command, in this case, the /sbin
directoryIf a command does not behave as expected or if a command is not accessible, that should be, it can be beneficial to know where the shell is finding the command
The
which
command searches for the location of a command in the system by searching the PATH
variableNote
The
PATH
variable contains a list of directories that are used to search for commands entered by the userViewing Man Pages
To view a man page for a command, execute the
To view the various movement commands that are available, use the H key or Shift+H while viewing a man page. This will display a help page
a summary of the more useful commands
man
command in a terminal windowTo view the various movement commands that are available, use the H key or Shift+H while viewing a man page. This will display a help page
a summary of the more useful commands
Sections Within Man Pages
Each man page is broken into sections. Each section is designed to provide specific information about a command. While there are common sections that you will see in most man pages, some developers also create sections that you will only see in a specific man page
The following table describes some of the more common sections that you will find in man pages
The following table describes some of the more common sections that you will find in man pages
NAME
Provides the name of the command and a very brief description.
كود:
NAME
ls - list directory contents
SYNOPSIS
A brief summary of the command or function’s interface. A summary of how the command line syntax of the program looks.
كود:
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
Provides a more detailed description of the command.
كود:
DESCRIPTION
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci-
fied.
OPTIONS
Lists the options for the command as well as a description of how they are used. Often this information is found in the
DESCRIPTION
section and not in a separate OPTIONS
section
كود:
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
--author
with -l, print the author of each file
-b, --escape
print C-style escapes for nongraphic characters
--block-size=SIZE
scale sizes by SIZE before printing them; e.g., '--block-size=M'
prints sizes in units of 1,048,576 bytes; see SIZE format below
FILES
Lists the files that are associated with the command as well as a description of how they are used. These files may be used to configure the command’s more advanced features. Often this information is found in the
DESCRIPTION
section and not in a separate FILES
section
AUTHOR
Provides the name of the person who created the man page and (sometimes) how to contact the person
كود:
AUTHOR
Written by Richard M. Stallman and David MacKenzie.
REPORTING BUGS
Provides details on how to report problems with the command
كود:
REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report ls translation bugs to <http://translationproject.org/team/>
COPYRIGHT
Provides basic copyright information
كود:
COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
Provides you with an idea of where you can find additional information. This often includes other commands that are related to this command
كود:
SEE ALSO
Full documentation at: <http://www.gnu.org/software/coreutils/ls>
or available locally via: info '(coreutils) ls invocation'
Until now, we have been displaying man pages for commands. However, sometimes configuration files also have man pages. Configuration files (sometimes called system files) contain information that is used to store information about the operating system or services
Additionally, there are several different types of commands (user commands, system commands, and administration commands) as well as other features that require documentation, such as libraries and kernel components
As a result, there are thousands of man pages on a typical Linux distribution. To organize all of these man pages, the pages are categorized by sections, much like each individual man page is broken into sections
Additionally, there are several different types of commands (user commands, system commands, and administration commands) as well as other features that require documentation, such as libraries and kernel components
As a result, there are thousands of man pages on a typical Linux distribution. To organize all of these man pages, the pages are categorized by sections, much like each individual man page is broken into sections
By default, there are nine sections of man pages
- Executable programs or shell commands
- System calls (functions provided by the kernel)
- Library calls (functions within program libraries)
- Special files (usually found in /dev)
- File formats and conventions, e.g. /etc/passwd
- Games
- Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
- System administration commands (usually only for root)
- Kernel routines [non-standard]
When you use the
man
command, it searches each of these sections in order until it finds the first match. For example, if you execute the command man cal
, the first section (Executable programs or shell commands) is searched for a man page called cal
. If not found, then the second section is searched. If no man page is found after searching all sections, you will receive an error messageDetermining Which Section
To determine which section a specific man page belongs to, look at the numeric value on the first line of the output of the man page. For example, if you execute the command
man cal
, you will see that the cal
command belongs to the first section of man pages
كود:
CAL(1) BSD General Commands Manual CAL(1)
Specifying a Section
In some cases, you will need to specify the section in order to display the correct man page. This is necessary because sometimes there will be man pages with the same name in different sections
For example, there is a command called
The
For example, there is a command called
passwd
that allows you to change your password. There is also a file called passwd
that stores account information. Both the command and the file have a man pageThe
passwd
command is a user command, so the following command will display the man page for the passwd
command, located in the first section, by default
كود:
PASSWD(1) User Commands PASSWD(1)
NAME
passwd - change user password
man
command. For example, the command man 5 passwd
will look for the passwd
man page in section 5 only:
كود:
PASSWD(5) File Formats and Conversions PASSWD(5)
NAME
passwd - the password file
Searching by Name
Sometimes it isn’t clear which section a man page is stored in. In cases like this, you can search for a man page by name
The
The
-f
option to the man
command will display man pages that match, or partially match, a specific name and provide a brief description of each man pageNote that on most Linux distributions, the
whatis
command does the same thing as man -f
. On those distributions, both will produce the same output.
كود:
sysadmin@SH3LL:~$ whatis passwd
passwd (1ssl) - compute password hashes
passwd (1) - change user password
passwd (5) - the password file
Searching by Keyword
Unfortunately, you won’t always remember the exact name of the man page that you want to view. In these cases, you can search for man pages that match a keyword by using the
For example, what if you knew you wanted a man page that displays how to change your password, but you didn’t remember the exact name? You could run the command
-k
option to the man
commandFor example, what if you knew you wanted a man page that displays how to change your password, but you didn’t remember the exact name? You could run the command
man -k password
كود:
sysadmin@SH3LL:~$ man -k password
chage (1) - change user password expiry information
chgpasswd (8) - update group passwords in batch mode
chpasswd (8) - update passwords in batch mode
cpgr (8) - copy with locking the given file to the password or gr...
cppw (8) - copy with locking the given file to the password or gr...
Warning
When you use this option, you may end up with a large amount of output. The preceding command, for example, provided over 60 results
Recall that there are thousands of man pages, so when you search for a keyword, be as specific as possible. Using a generic word, such as “the” could result in hundreds or even thousands of results
Note that on most Linux distributions, the
Note that on most Linux distributions, the
apropos
command does the same thing as man -k
. On those distributions, both will produce the same outputعايز تعرف اكتر عنman
…جرب
man man
كول مش كدة ؟؟؟![]()
![]()
و أخيرا … لو وصلت لهنا وقريت كل اللي فوق دة


التعديل الأخير: