Linux Unix Advance Commands

Linux Unix Advance Command


File Command

The file command determines the file type of a given file. For example:

$ file /etc/passwd
/etc/passwd: ASCII text

You can provide one or more than one file as an argument to the file command.

$ file td.c td.out ARP.java Screenshot.png StringTokenizing.class
idl.rar List.pdf
td.c: ASCII C program text, with CRLF line terminators
td.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
ARP.java: ASCII Java program text, with CRLF line terminators
Screenshot.png: PNG image data, 1366 x 768, 8-bit/color RGB, non-interlaced
StringTokenizing.class: compiled Java class data, version 50.0 (Java 1.6)
idl.rar: RAR archive data, v1d, os: Win32
List.pdf: PDF document, version 1.4

stat command

To check the status of a file. This provides more detailed information about a file than ‘ls -l’ output.

$ stat usrcopy
File: `usrcopy
Size: 491 Blocks: 8 IO Block: 4096 regular file
Device: 808h/2056d Inode: 149452 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ raghu) Gid: ( 1000/ raghu)
Access: 2012-07-06 16:07:06.413522009 +0530
Modify: 2012-07-06 16:02:30.204152386 +0530
Change: 2012-07-06 16:17:18.992559654 +0530

Changing permissions (chmod command)

r (read) = 4

w (write) = 2

x (execute) = 1

no permissions = 0

chmod 644 filename

Only root, the file owner, or user with sudo privileges can change the permissions of a file.

chmod -R 755 dirname

Changing ownership (chown command)

$ chown username filename
$ chown username:groupname filename
$ chown -R username:groupname dirname

Elevate privileges (sudo command)

sudo command

Creating users (useradd and passwd Commands)

$useradd newuser
$passwd newuser

Removing users (userdel Command)

$ userdel newuser
$ userdel -r newuser

Managing groups (groupadd and groupdel Command)

$ groupadd mygroup
$ groupdel mygroup

Adding users to groups (usermod Command)

usermod -a -G sudo linuxize


Post a Comment

0 Comments