0% found this document useful (0 votes)
10 views5 pages

Linux Command Exercises

This document provides 57 examples of Linux commands to list, move, copy, and delete files and directories, and to modify their permissions and ownership. The commands include ls, cd, mkdir, rm, cp, mv, chmod, and others to navigate the file system, create nested directory structures, and manage the permissions and ownership of files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Linux Command Exercises

This document provides 57 examples of Linux commands to list, move, copy, and delete files and directories, and to modify their permissions and ownership. The commands include ls, cd, mkdir, rm, cp, mv, chmod, and others to navigate the file system, create nested directory structures, and manage the permissions and ownership of files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Linux command exercises

1.- List all files in the bin directory.


The command 'ls /bin' is not translatable text.

2.- List all files in the tmp directory.


list directory contents of /tmp

3.- List all files in the etc directory that start with t in reverse order.

ls -r /etc/t*

4.- List all the files in the dev directory that start with tty and have 5 characters.

ls /dev/tty??

5.- List all files in the dev directory that start with tty and end with 1, 2, 3, or 4.

list /dev/tty*[1-4]

6.- List all the files in the dev directory that begin with t and end with C1.

ls /dev/t*c1

7.- List all files, including hidden ones, from the root directory.

ls -a /

8.- List all files in the etc directory that do not start with t.
list directories in /etc that do not start with 't'

9.- List all files in the usr directory and its subdirectories.
Invalid input. Please provide a text to translate.

10.- Change to the tmp directory, create the PRUEBA directory.

cd /tmp mkdir TEST

11.- Verify that the current directory has changed.

pwd

12.- Show the current day and time.

date

13.- With a single command, navigate to the $HOME directory.

cd /home

14.- Check that you are in it.


pwd

15.- List all the files in the HOME directory showing their inode number.

ls -i

16.- Delete all visible files and directories from your TEST directory.

rm -rf PRUEBA/*

17.- Create the directories dir1, dir2, and dir3 in the PRUEBA directory. Inside dir1 create the
directory dir11. Inside the directory dir3 create the directory dir31. Inside the directory dir31,
create the directories dir311 and dir312.

mkdir TEST/dir1

mkdir TEST/dir1/dir11

mkdir TEST/dir2

mkdir TEST/dir3

mkdir TEST/dir3/dir31

mkdir TEST/dir3/dir31/dir311

mkdir TEST/dir3/dir31/dir312

18.- Copy the file /etc/motd to a file named message in your PRUEBA directory.

sudo touch /etc/motd TEST/message

19.- Copy the files from the rc.d directory located in /etc to the dir31 directory.

cp -r /etc/rc.d dir31

20.- Copy to the directory dir311 the files from /bin that have an 'a' as the second letter and their
name has four letters.

cp -r /bin/?a?? TEST/dir3/dir31/dir311

21.- Move the directory dir31 and its subdirectories under dir2.

move PRUEBA/dir3/dir31 PRUEBA/dir2

22.-Display on screen the ordinary files of the HOME directory and its subdirectories.

ls -R $HOME

23.-Delete the files and directories from dir1, including the directory itself.

rm -rf TEST/dir1

24.- Delete the files from dir312 that do not end in b and have a q as the fourth letter.

rm -r PRUEBA/dir2/dir31/dir312/???q[^b]
25.-Move the directory dir312 under dir3.

move PRUEBA/dir2/dir31/dir312 PRUEBA/dir3

26. - Navigate to dir3 and create the new directory new1 inside dir1.

cd dir3 mkdir enlacedir1/nuevo1

27.-Copy the files that start with u from the /bin directory to the new1 directory.

cp -r /bin/u* enlacedir1/nuevo1/

28.-Delete the file fich1.

rm fich1

29.- Position yourself in dir1 and copy the file fichl into dir311.

cd dir1 cp enlafich1 ../dir2/dir31/dir311/fich1

30.- Print the lines that the file fich1 has.

cat enlafich1

31.- Delete the file fich1 from dir2.


remove dir2/file1

32.- Create the directories dir2 and dir3 in the directory TEST. What are the current permissions of the
directory dir2?

create directory dir1

33.- Using symbolic notation, remove all write permissions (owner,


group, others) of the directory dir2.

chmod 555 dir2

34.- Using octal notation, remove the read permission from the directory dir2 for the rest of the
users.

chmod 551 dir2

35.- What are the permissions now associated with dir2?

ls -l

36.- Create a directory called dir2l under dir2.

mkdir dir2/dir21 cannot be created permission denied

37.- What are the default values assigned to files?

ls -l dir2
38.- Change the current directory to the dir3 directory. Print its full path for
check the change.

cd .. cd dir3 ls -lR

39.- What permissions were assigned to this directory at that time?

ls -lR

40.-Restart the computer.

reboot

41.- Create four new directories called dira, dirb, dirc, and dird under the current directory.

mkdir dira mkdir dirb mkdir dirc mkdir dird

42.-Check the access permissions of the newly created directories to verify the
functioning of the umask command.

ls -l

43.-Create the file one. Remove all read permissions. Check it. Try to delete it.
said file.
create one chmod a-r one ls -l remove one

44.- Create in your own directory:

The directory folder1 with three permissions for the owner, inside it file1 with read and
writing for all and fich2 with read and write for the owner and read only for the
restaurant.

The directory folder2 with all permissions for the owner and read and execute for others.
from the same group. Within file1 with read and write permissions for the owner and the group and file2
with the same permissions for the owner and read-only for the group.
create folder1 set permissions u=rwx,g=,o= folder1 create file folder1/file1 create file folder1/file2 set permissions =
folder1/file1 chmod = folder1/file2 chmod o=rw folder1/file1 ls -l
create directory folder2 change permissions user=read-write-execute, group=read-execute, others= folder2 create file folder2/file1 create file folder2/file2 change permissions =

folder2/file2 chmod = folder2/file1 chmod u=rw,g=rw folder2/file1 chmod u=rw,g=r


carpeta2/file2 ls -l

45.-Create two directories called mail and sources under the current directory.
create directory mail create directory sources

46.- Position yourself in the sources directory and create the directories dir1, dir2, dir3.

cd sources mkdir dir1 mkdir dir2


47.-Create the menus directory under mail without moving from the current directory.
create directory ../correo/menus

48.- Position yourself in the HOME directory

cd $HOME

49.- View the permissions for the files in the /dev directory.

ls -l /dev

50.- View the list of all files belonging to root.

find / -user root -type f

51.- Create the directory uno1 with all permissions for the user, none for the users
of the group and write permission for the rest of the users.
Change the permissions of the directory 'uno' so that the owner and group have read, write, and execute permissions, and others have no permissions. Create a directory 'uno1' inside 'uno'. Change the permissions of 'uno1' so that the owner has read, write, and execute permissions, the group has no permissions, and others have write permissions. List the details of the directory 'uno1'.

52.- Visualize the relationship of connected users and their terminals.

who

53.- Create the directory folder under the PRUEBA directory. Remove all permissions from it.
reading.
create directory folder change mode to remove read permission from folder find home directory -type directory > directory

54.- Display a complete list (search command ps) of the processes that are
performing as the root user.

ps -U root -u root u

55.- Find out what the current activity of the system is. To do this, view a complete list of
status of all processes that are running in the system.

top -d 1 -n 10

56.- Show how many users are connected

who -q

57.- clear screen

You might also like