TP2 Linux
TP2 Linux
• The Linux command-line interface provides powerful utilities for file manipulation,
process management, and system monitoring. Tools like grep, sed, awk, and bash
scripting give users fine-grained control over tasks.
• It allows automation and scripting for repetitive tasks, boosting productivity for users
and system administrators.
Networking:
• Linux is widely used in networking environments due to its flexibility and reliability. It
powers a majority of the world’s web servers, routers, firewalls, and networked devices.
• Utilities like ssh, scp, iptables, and rsync make Linux a preferred choice for system
administrators.
• Linux provides a rich environment for software development with a wide variety of
programming languages, tools, and compilers (such as gcc for C, Python, Java, etc.).
• It's popular in DevOps and cloud computing environments due to its support for
containers (e.g., Docker) and orchestration tools (e.g., Kubernetes).
Compatibility:
• Linux supports a vast range of file systems and hardware devices, making it highly
compatible for different tasks. It also supports virtualization platforms, enabling users to
run other operating systems alongside Linux.
Community Support:
• Linux has a large, active community of developers and users who contribute to its
development and provide support through forums, documentation, and collaborative
tools.
Privacy:
• Unlike some proprietary operating systems, Linux doesn’t track user data. This makes it
an attractive option for privacy-conscious users.
Summary of commands
example:
mkdir test
rm test
rm -rf test
example1:
touch file1.txt
touch file2.txt
touch file3.txt
ls
rename ‘s/\.txt/\.png/’ *.txt : it is used to search for all files ending with .txt in the current
directory and rename them to have a .png extension instead. For example, file1.txt will be
renamed to file1.png.
wget “https://www.usm.uni-
muenchen.de/people/puls/lessons/intro_general/Linux/Linux_for_beginners.pdf “ -o
linux_biginners.pdf
Exercice 2:
Exercice 3:
1. head is used to display the first ten lines of a file : try this head /etc/passwd
2. tail is used to display the last ten lines of a file : try this tail /etc/passwd
you can add the number of lines you want to see : tail -4 /etc/passwd
cat part1
cat part2
cat part3
cat all
cat winter.txt
6. You can choose an end marker for cat with << You can choose an end marker
for cat with << like this :
cat > hot.txt <<stop
It is hot today!
Yes it is summer.
stop
cat hot.txt
7. cat is also used to copy files.
cat winter.txt
cat cold.txt
cat count
tac count
Create three text files named file1.txt, file2.txt, and file3.txt. Each file should contain one or two
lines of text describing any topic. Then, perform the following:
• Concatenate the contents of all three files and display the result on the screen.
• Concatenate the three files and save the result in a new file called combined.txt, then
display the contents of combined.txt.
Exercice 4:
Create a simulated log file server.log that contains entries with timestamps, statuses, and
messages :
EOF
EOF
Automatically archive the first 5 entries of the log file into a file named server_archive.log, then
remove them from the original log file: