Linux Terminal | Linux all commands

In a terms of managing files, accounting and other official work linux is awesome and it's GUI is prety easy now days, but as far as CLI (command line interface) is concerned in administrative task like managing server, using CLI is consider faster than GUI but hard to learn commands. Practice over commands can help.

File Commands

pwd
locat the directory in which we are in, see present directory
touch
make file in directory
mkdir
make empty directory
rm
remove only files
rm -r *
remove everything empty and non empty directory and files.
new\ file
give "\" to make the file name of "new file"
ls -l
see listed files and directory along with user group other permissins
ls -a
see all files and directory, hidden also
ls -gG
list file in directory, ignore user and group
cp -r
copy files and directory
cat
see inside the file
poweroff
shutdown the machine
reboot
Restart the machine
ps
display your currently active processes
top
display all running processes
killall pro
kill all processes named proc*
man cat
see help for "cat"

File Permissions

4 read (r)
2 write(w)
1 execute(x)

chown user1 filename
change ownership of file to user1
chmod 777 /home
read, write, execute for all
chod o+rwx
add read, write and execute permission to other(outside the world)
chmod g+wx
Add Write and execute permission to groups
chmod -R 777 data
for recursively set permission
chmod u-w
remove write permission from user

User and groups commands

passwd user1
set password for user1
useradd username --shell /bin/false
create user without accessing the shell
usermod -aG sudo rahul
Add rahul into sudo group
adduser rahul
add user name rahul
addgroup groupname
create a group named groupname
sudo usermod -a -G groupName userName
Add user into the group

Searching

grep -r pattern dir
search recursively for pattern in dir
locate file
find all instances of file

system information

date
show the current date and time
cal
show this month's calendar
uptime
show current uptime
w
display who is online
whoami
who logged in
finger user
display about logged user
uname -a
display about system
cat /proc/cpuinfo
cpu information
cat /proc/meminfo
memory information
man
show the manual of commands
free
show memory and swap usage
whereis app
show possible locations of app
which app
show which app will be run by default

network commands

ping host
output host results
whois domain
get whois information for domain
dig domain
get DNS inormation for domain
dig -x host
reverse lookup host
wget file
download file
wget -c file
continue stopped file to download
nano /etc/network/interfaces
configuration of network interface
ifconfig eth0 down
down the eth0 (interface)
service network-manager restart
restart the network services

installation commands

dpkg --get-selection
view installed package
dpkg --get-selection | grep python
list installed package starting name from python
dpkg -i package.deb
install package debian
rpm -Uvh pkg.rpm
install a package (RPM)
apt-get reove package
remove software using package name like "samba"

install from source
./configure
make
make install

Terminal shortcut

Ctrl+C
halt the current command
Ctrl+Z
Stops the current command, resume with fg in the foreground or bg in the background
Ctrl+D
Log out of current session, same as exit
Ctrl+W
erases one word in the current line
Ctrl+U
erases whole line
Ctrl+Shift+C
copy select commands

Disk and drive command

fdisk -l
list storage device
lsblk
list storage device
blkid
list storage device with uuid
fdisk /devsdb
Partition the disk press n to create p for primary w for write changes
mkfs -t ext4 /dev/sdb1
format with ext4
"uuid" /mnt/mydrive ext4 defaults 0 0
mount at boot
ntfsfix /dev/sda#
fix ntfs drive
mount -t ext4 /dev/sdab# /mnt/data
mount ext4 drive in data directory
mount -a /dev/sdab# /mnt/data
mount drive for auto file system selection

DNS configuration

dpkg-reconfigure resolvconf
press ok, and reboot the machine

Samba file sharing

apt-get install smbclient
for installation of windows shared printer
apt-get install samba
if samba not installed in system,
smbpasswd -a user1
Samba uses a separate set of password than the standard linux system account stored in /etc/samba/smbpasswd
nano /etc/samba/smb.conf
configura smb.conf file for file and printer sharing

win support = yes
security = user
[share]
comment = file sharing
path = /DATA
valid users = user1 user5
public = yes
create mask = 0775
read only = no
writable = yes
guest ok = yes
service smbd restart

smbclient -L //ip/share -U username
access shared folder

Comments

Popular

icegate registration with dsc | Unable to execute PKI Component

MFS100 mantra driver installation and RD service

Repair Hikvision IP Camera | Cable color codding