Linux Command
cat /etc/passwd
• To show userlist .
sudo useradd user1 –g 1001
• create new user with group id 1001
sudo groupadd –g 1002 group1
• Add new group “group1” with group id 1002
sudo usermod user1 -g 1002
• Assign user1 in new group which id is 1002
mkdir {os-concepts,ubuntu-is-the-best}
• Create multiple file in one command in home Directory.
cd os-concepts
• To change Directory home to newly Created os-concepts
touch file1,file2
• To create 2 file
ls –l
• To show the permission of the file where w indicates write, r indicates Read and x indicate Execute.
To update file permissions so that the owner can read and write, the group can only read, and others have no permissions, you can use the chmod command in Linux with the following syntax • chmod 640 file1.txt,file2.txt In this command: 6 represents read (4) + write (2) permissions for the owner. 4 represents read permission for the group. 0 represents no permissions for others.
sudo groupadd –g 1010 newsgroup
• Create new group with id 1010 which name is newsgroup.
To update ownership of a file to the newly created group you can use chown command.
• sudo chown :newgroup file.txt,file2.txt
To assign user1 to newly created group which gid is 1010
• sudo usermod –a –G newgroup user1
To create a file named "crash.in" containing the word "crash" in different directories and then find those files using the find command, you can follow these steps:
• echo "crash" > ~/os-concept/crash.in
• echo "crash" > ~/ubuntu-is-the-best/crash.in • echo "crash" > ~/Desktop/crash.in
find ~/ -name "crash.in"
• Use the find command to locate all instances of the file. • This command will search for files named "crash.in" starting from the root directory (/) and display the paths to all matching files.
find ~/ -name "crash.in" -print0 | xargs -0 sed -i 's/crash/broken/g'
• find / -name "crash.in" -print0: This finds all files named "crash.in" starting from the home directory () and prints the file paths with null terminators (to handle filenames with spaces or special characters).
• xargs -0 sed -i 's/crash/broken/g': This takes the output of the find command and uses xargs to execute sed on each file. The sed command (sed -i 's/crash/broken/g') replaces all occurrences of "crash" with "broken" in each file in-place. After running this command, all instances of "crash" in the "crash.in" files within the specified directories will be replaced with "broken".