MOST USEFUL COMMANDS FOR TERMUX AND LINUX | UNKNOWN HACKER ASP
If yet you don't known about termux go and read What is Termux post...
Termux Package Installation
In Termux it is recommended to use package manager pkg which is a wrapper for apt. It simplifies installing or upgrading packages by automatically updating apt lists so you dont have to type apt update when installing or upgrading packages.

Install package:
pkg install [package name]
Remove package:
pkg uninstall [package name]
List all packages:
pkg list-all

pkg install [package name]
Remove package:
pkg uninstall [package name]
List all packages:
pkg list-all
Manual installation of *.deb files
If you have a *.deb package file, you can install it with dpkg. Note that packages downloaded from Ubuntu or from repositories of other Linux distributions will not work due to incompatible libc ABI, however statically compiled binaries may work.

Installing:
dpkg -i ./package.deb
Uninstalling:
dpkg --remove [package name]
Listing all installed packages:
dpkg -l
dpkg -i ./package.deb
Uninstalling:
dpkg --remove [package name]
Listing all installed packages:
dpkg -l
pwd Command
Show Current Direcctory
$ pwd
cal command
Displays the calendar of the current month.
$ cal July 2012 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
echo command
This command will echo whatever you provide it.
$ echo "linoxide.com" linoxide.com
The ‘echo’ command is used to display the values of a variable. One such variable is ‘HOME’. To check the value of a variable precede the variable with a $ sign.
$ echo $HOME /home/raghu
Date Command
Displays current time and date.
$ date Fri Jul 6 01:07:09 IST 2012
If you are interested only in time, you can use date +%T (in hh:mm:ss):
$ date +%T 01:13:14
tty command
Displays current terminal.
$ tty /dev/pts/0
whoami command
This command reveals the user who is currently logged in.
$ whoami raghu
id command
This command prints user and groups (UID and GID) of the current user.
$ id uid=1000(raghu) gid=1000(raghu) groups=1000(raghu),4(adm),20(dialout),24(cdrom),46(plugdev),112(lpadmin),120(admin),122(sambashare)
By default, information about the current user is displayed. If another username is provided as an argument, information about that user will be printed:
$ id root uid=0(root) gid=0(root) groups=0(root)
clear command
This command clears the screen.
$ clear
help option
With almost every command, ‘--help’ option shows usage summary for that command.
$ date --help Usage: date [OPTION]... [+FORMAT] or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] Display the current time in the given FORMAT, or set the system date.
whatis command
This command gives a one line description about the command. It can be used as a quick reference for any command.
$ whatis date
date (1) - print or set the system date and time
$ whatis whatis
whatis (1) - display manual page descriptions
Manual Pages
‘--help’ option and ‘whatis’ command do not provide thorough information about the command. For more detailed information, Linux provides man pages and info pages. To see a commands manual page, man command is used.
$ man date
The man pages are properly documented pages. They have following sections:
NAME: The name and one line description of the command.
SYNOPSIS: The command syntax.
DESCRIPTION: Detailed description about what a command does.
OPTIONS: A list and description of all of the commands options.
EXAMPLES: Examples of command usage.
FILES: Any file associated with the command.
AUTHOR: Author of the man page
REPORTING BUGS: Link of website or mail-id where you can report any bug.
SEE ALSO: Any commands related to the command, for further reference.
With -k option, a search through man pages can be performed. This searches for a pattern in the name and short description of a man page.
$ man -k gzip gzip (1) - compress or expand files lz (1) - gunzips and shows a listing of a gzip d tar d archive tgz (1) - makes a gzip d tar archive uz (1) - gunzips and extracts a gzip d tar d archive zforce (1) - force a .gz extension on all gzip files
Info page
Info documents are sometimes more elaborate than the man pages. But for some commands, info pages are just the same as man pages. These are like web pages. Internal links are present within the info pages. These links are called nodes. Info pages can be navigated from one page to another through these nodes.
$ info date
Changing Directories Command
$ cd [path-to-directory]
Change the current working directory to the directory provided as argument. If no argument is given to ‘cd’, it changes the directory to the users home directory. The directory path can be an absolute path or relative to current directory. The absolute path always starts with /. The current directory can be checked with ‘pwd’ command (remember?):
$ pwd /home/raghu $ cd /usr/share/ $ pwd /usr/share $ cd doc $ pwd /usr/share/doc
In the first ‘cd’ command, absolute path (/usr/share) is used, and with second command, relative path (doc) is used.
Listing File And Directories Command
$ ls [files-or-directories]
List files and/or directories. If no argument is given, the contents of current directory are shown.
$ ls
example file1.txt file2.txt file3.txt
If a directory is given as an argument, files and directories in that directory are shown.
$ ls /usr
bin games include lib lib64 local sbin share src
‘ls -l’ displays a long listing of the files.
$ ls -l total 4 drwxr-xr-x 2 raghu raghu 4096 2012-07-06 12:52 example -rw-r--r-- 1 raghu raghu 0 2012-07-06 12:52 file1.txt$ ls -la odesk total 16 drwxr-xr-x 4 raghu raghu 4096 2012-07-06 13:46 . drwxr-xr-x 11 raghu raghu 4096 2012-07-06 13:15 ..
If you want to see the properties of a directory instead of the files contained in it, use -d (with -l) option:
$ ls -ld odesk/ drwxr-xr-x 4 raghu raghu 4096 2012-07-06 13:46 odesk/
Creating files and directories
mkdir command
To create a directory, the ‘mkdir’ command is used.
$ mkdir example $ ls -l total 4 drwxr-xr-x 2 raghu raghu 4096 2012-07-06 14:09 example
touch command
For creating an empty file, use the touch command.
$ touch file1 file2 file3 $ ls -l total 4 drwxr-xr-x 2 raghu raghu 4096 2012-07-06 14:09 example -rw-r--r-- 1 raghu raghu 0 2012-07-06 14:20 file1
If a file already exists, touch will update its time stamp. There are a lot of other methods to create a new file, e.g. using a text editor like vi or gedit, or using redirection. Here is an example of creating a file using redirection:
$ ls -l /usr > usrlisting $ ls -l total 8 drwxr-xr-x 2 raghu raghu 4096 2012-07-06 14:09 example -rw-r--r-- 1 raghu raghu 0 2012-07-06 14:20 file1 -rw-r--r-- 1 raghu raghu 0 2012-07-06 14:20 file2 A file named usrlisting is created in this example.
copy command
$cp source destination
Copy files and directories. If the source is a file, and the destination (file) name does not exit, then source is copied with new name i.e. with the name provided as the destination.
$ cp usrlisting listing_copy.txt$ cp listing_copy.txt example/$ cp -r example /tmp/expertslogin/$ ls -l /tmp/expertslogin total 4 drwxr-xr-x 2 raghu raghu 4096 2012-07-06 16:12 example
move command
$ mv source destination
Move files or directories. The mv command works like cp command, except that the original file is removed.
But, the mv command can be used to rename the files (or directories).
$ mv listing_copy.txt usrcopy
Here, listing_copy.txt is moved with the name usrcopy in the same directory (or you can say that it has been renamed).
To remove or Delete
$ rmdir
rmdir command removes any empty directories, but cannot delete a directory if a file is present in it.
To use ‘rmdir’ command, you must first remove all the files present in the directory you wish to remove (and possibly directories if any).
To remove files and directories
$ rm files|directories$ rm file2$ rm file.txt
cat command
The cat command is actually a concatenator but can be used to view the contents of a file.
$ cat /etc/passwd
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
Update - Upgrade
$ apt -get update$ apt -get upgrade
use Both:
$ apt -get update && upgrade

Comments
Post a Comment