هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
المهارات في هذا الفصل
- تسجيل الدخول وتنفيذ الأوامر في Bash
Log in on the console or in the desktop
You start a shell by logging in. On a server that is a text console, on a workstation the GNOME desktop with a terminal window.
- Text console: the server shows
server1 login:. Type the user name, press Enter, type the password (you see nothing while you type) and press Enter. - GNOME desktop: click your name, type the password. Open Activities, type
terminaland start Terminal (or pressSuper, the Windows key). - Virtual consoles: a Linux machine has several text consoles. Switch with
Ctrl+Alt+F1…Ctrl+Alt+F6. On RHEL 10 the graphical login is on the first one.
Red Hat Enterprise Linux 10.0 (Coughlan)
Kernel 6.12.0-55.9.1.el10_0.x86_64 on x86_64
server1 login: student
Password:
[student@server1 ~]$في العمل
Servers in a data center usually have no desktop. You log in over SSH (next lesson) or with the console of the virtual machine or of the server's management card (iDRAC, iLO).
Log in to another machine with SSH
ssh user@host opens a secure shell on another computer over the network. Everything — also the password — is encrypted.
ssh student@server2
The authenticity of host 'server2 (192.168.122.20)' can't be established.
ED25519 key fingerprint is SHA256:Wp1tH3d2c0QhC8bXl9Zr5yJm6nK4aP7sT0uV2xY3zA8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
student@server2's password:
[student@server2 ~]$ hostname
server2.example.com
[student@server2 ~]$ exit
logout
Connection to server2 closed.- The first time, SSH shows the fingerprint of the server's host key. Type
yesonly when you trust it. SSH saves it in~/.ssh/known_hosts. ssh server2without a user name uses your local user name.ssh -i key.pem ec2-user@HOSTlogs in with a key file — normal in public clouds.
انتبه
If SSH later shows WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED, stop. Either the server was reinstalled, or somebody is between you and the server. Check with the server owner before you remove the old key.
More about keys and the SSH server: Set up and secure SSH.
Read the shell prompt
The prompt tells you who you are, where you are and how strong you are.
[student@server1 ~]$
[root@server1 /etc]#| Part | Meaning |
|---|---|
student / root | The user name |
server1 | The short host name |
~ / /etc | The current folder (~ = your home folder) |
$ | A normal user |
# | The superuser root: no limits, be careful |
whoami
student
id
uid=1000(student) gid=1000(student) groups=1000(student),10(wheel)
pwd
/home/studentتذكّر
In these summaries, $ lines run as a normal user and # lines need root (or sudo).
Type a command the right way
A command line is command + options + arguments, with spaces between them. Linux is case-sensitive: ls works, LS does not.
- Options change how the command works. Short options: one dash and a letter (
-l), you can join them (-la). Long options: two dashes and a word (--all). - Arguments say what the command works on: files, folders, users, packages.
- A file name with spaces needs quotes:
ls -l "my report.txt".
Some simple commands to try:
date
Mon Oct 27 09:15:02 AM +03 2026
date +%F
2026-10-27
cal
file /etc/passwd /usr/bin/ls
/etc/passwd: ASCII text
/usr/bin/ls: ELF 64-bit LSB pie executable, x86-64
wc -l /etc/passwd
38 /etc/passwd
head -n 3 /etc/passwd
tail -n 3 /var/log/dnf.logانتبه
Before you press Enter on a command that deletes or changes things, read it again. The shell does not ask "are you sure?".
Run several commands on one line
; runs commands one after the other. && runs the next one only when the first one worked. || runs the next one only when the first one failed.
cd /tmp ; ls
mkdir -p /tmp/test && cd /tmp/test
ping -c 1 server2 > /dev/null || echo "server2 does not answer"
dnf check-update -q || echo "updates are waiting"Every command ends with an exit status: 0 = OK, any other number = a problem. $? shows the status of the last command.
ls /etc/passwd
/etc/passwd
echo $?
0
ls /nothing
ls: cannot access '/nothing': No such file or directory
echo $?
2تذكّر
&& = "and if OK", || = "or else", ; = "then, no matter what".
Let Tab type for you
Press Tab once to complete a command, a file name, an option or a service name. Press Tab twice to see all choices.
Repeat commands from the history
Bash remembers the commands you typed. Repeat them instead of typing them again.
| Keys / command | What it does |
|---|---|
| ↑ / ↓ | Walk through the last commands |
Ctrl+R, then type | Search back in the history. Ctrl+R again: older match. Enter runs it. |
!42 | Run line 42 again |
!! | Run the last command again |
!ss | Run the last command that started with ss |
Esc . or Alt+. | Paste the last argument of the previous command |
The history is saved in ~/.bash_history when you log out. Details: the RHCSA lesson about history.
Edit the command line fast
You do not need the arrow keys to fix a long command. These keys move and delete fast.
| Keys | What they do |
|---|---|
Ctrl+A / Ctrl+E | Go to the start / end of the line |
Alt+B / Alt+F | Go one word back / forward |
Ctrl+W | Delete the word before the cursor |
Ctrl+U / Ctrl+K | Delete from the cursor to the start / to the end |
Ctrl+Y | Paste back what you deleted last |
Ctrl+L | Clear the screen (same as clear) |
Ctrl+C | Stop the running command, or drop the line you are typing |
Ctrl+D | End of input; on an empty prompt it logs you out |
A long command can go over several lines: end a line with \ and go on in the next line.
rsync -av --delete \
/srv/www/ \
backup@server2:/backup/www/Log out and end the session
Always log out when you are done, also on a test server. An open root shell is an open door.
exit
logoutexit(orCtrl+D) ends the shell. In an SSH session you are back on your own machine.- In GNOME, use the menu at the top right: Log Out or Power Off.
wandwhoshow who else is logged in.
w
09:31:10 up 2 days, 3:12, 2 users, load average: 0.02, 0.05, 0.01
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
student pts/0 09:02 0.00s 0.04s 0.00s w
anna pts/1 08:47 20:11 0.01s 0.01s -bash