Kuk Linux 2023
Q2 :- Write the command and its syntax for following action and also explain the command :
(i) View name of files in desending order by time wise.
(ii) Create new user with shell specified.
(iii) View test.test files with permission and change
permission from rw-r-rw- to rwxrw-r--
(i) View name of files in descending order by time-wise
Command:ls -ltSyntax:
ls -lt [directory]
Explanation:
lsis the command to list directory contents.-loption provides a detailed listing (long format) which includes file permissions, number of links, owner, group, size, and time of last modification.-toption sorts the files by modification time, with the newest files first.- When combined (
-lt), it lists files in long format sorted by time in descending order.
ls -lt /path/to/directory
(ii) Create a new user with a specified shell
Command:useradd -sSyntax:
sudo useradd -s /path/to/shell username
Explanation:
useraddis the command to create a new user.-soption allows specifying the user’s login shell.sudois used to execute the command with superuser privileges, which is typically required for user management.
sudo useradd -s /bin/bash newuser
(iii) View test.test file with permissions and change permissions from rw-r--rw- to rwxrw-r--
To view the file permissions:
Command:
ls -lSyntax:
ls -l test.test
Explanation:
ls -llists files in long format, showing detailed information including file permissions.
ls -l test.test
To change the file permissions:
Command:
Syntax:
Command:
chmodSyntax:
chmod 764 test.test
Explanation:
chmodis the command to change file permissions.- The numerical representation
764translates to:7(rwx) for the owner6(rw-) for the group4(r–) for others
chmod 764 test.test
