Common Unix/Linux Commands used via Telnet
Common Unix/Linux Commands used via Telnet
cd
When typed by itself, cd (”change directory”), will take you back to your $HOME directory
cd /path/to/directory
To change to a specific directory, type cd followed by the path to the directory. If it is a subdirectory of the current directory, you can just type the directory name.
cd ..
Typing cd .. moves you up one directory from your current location.
pwd
To see which directory you are in, type pwd (”print (display) working directory”).
exit
Just as it sounds, use exit to log out. Alternatively, you can type logout.
Creating and Deleting Directories
mkdir directoryname
To create a new directory, type mkdir (”make directory”) and specify the new directory’s name.
rmdir directoryname
To delete an empty directory, type rmdir (”remove directory”) and the directory’s name.
Listing Files
ls
To display a list of files and subdirectories in your current directory, type ls (”list”)
ls -a
To see a more complete list which includes hidden files or files that begin with a “.” (dot), type ls -a.
ls -la
To list all files and directories in long format which will provide details about each file and directory, type ls -la.
ls -lS
To list all directories and files, sorted by size, in long format, type ls -lS.
ls -lta
To list all files and directories in long format by time modified, type ls -lta.
Copying Files
cp oldfilename newfilename
Will copy the contents of one file to another file, resulting in two copies of the same file on your account.
cp directory/* destinationdirectory
Will copy the contents of one directory to another directory. Make sure you have created the destination directory before trying to copy files to it - see mkdir above. Results in two copies of the files on your account; one copy in the existing directory and another in the destination directory.
Searching FIles and Directories
find -name ‘n*’
The find command can be used to locate files or a group of files. It can also be used to display directories. The example given will find all file and directory names within the current directory and subdirectories of it that begin with the letter n. (You can also explore using the locate command - type info locate and/or man locate for usage information.)
grep -inw text filename
Can be used to locate text in a specific file or directory of files (use * in place of filename to search all of the files in the current directory). The -i argument indicates the search is to disregard cASe, the -n instructs to show the corresponding line number, and -w tells it to match only based on the whole word. (This doesn’t even begin to touch on the power of grep and its many uses. In addition to its searching capability, the grep command can be used in combination with other commands to act as a filter. It also allows the use of “wildcards”. Two other variations of grep are also available, egrep and fgrep. To begin your quest for more information, type man grep and/or info grep.)
Displaying / Comparing File Content
wc filename
Counts and displays the number of lines, number of words, and number of characters of the given file.
cat filename
Displays the entire contents of a file.
nl filename
Shows the content of the file, including line numbers (nl=number lines).
more filename
Displays the contents of a file one screen at a time. Press the SPACEBAR to display the next screen of text.
cmp filename1 filename2
Compares the contents of the two named files and reports the first different character found and the line number.
diff filename1 filename2
Compares the contents of the two named files and reports all of the differences found. (Can also be used for comparing the contents of two directories.)
Moving, Renaming, and Deleting Files
mv oldfilename newfilename
Can be used to rename a file (mv fileA fileB), move a file (mv fileA /dirA/), or both (mv fileA /dirB/fileB).
rm -i filename
Removes (deletes) the specified file. (The -i is not necessary, but is recommended as it will prompt you to confirm the action first. When prompted, type y to confirm or type n if you changed your mind.)
Changing Permissions
chmod permissions filename
Changes the permissions on a filename or directory as specified. For example, chmod 755 startup.sh.
Archives and Compression
tar -cfv filename.tar directoryname
To archive a directory and all of its contents including subdirectories, navigate to where the directory is located and type the above command, replacing filename.tar with the name you wish to give the archive file and directoryname with the name of the directory you wish to archive. Alternatively, you can archive a select group of individual files (or directories) by specifying each file name in place of directoryname separated by spaces, like tar -cvf filename.tar fileA fileB fileC. Note: When creating a tar file (aka “tarball”) be sure to specify the name you wish to give the tar file! (TAR indicates Tape ARchive, as it was originally a tape archiving program. The -c means “create”, v means “verbose” (which basically says tell me what you’re doing), and the f indicates that a filename will follow (filename.tar)).
tar -tvf filename.tar
Typing this command will result in a list of the contents of the tar file. This is generally a good thing to do before unpacking the tar file to be sure there are no matching filenames which will result in files being unintentionally overwritten.
tar -xvf filename.tar
You can see the similarities to the command used to tar the file. This time, though, you use -x to “extract” instead of the -c used to create. You can also extract only certain select files (or directories) by specifying the individual names, separated by spaces, after the tar filename, such as tar -xvf filename.tar fileA fileC
gzip filename.tar
This utility, gzip (gnu zip), is used for compression. Normally, when you wish to compress a set of files, you willtar them first then compress them using this command. In doing so, the filename will automatically change from filename.tar to filename.tar.gz (appending .gz to the file extension).
gunzip filename.tar.gz
This command (g”unzip”) is used to uncompress a .tar.gz file, which will also result in the filename being changed back to filename.tar. Once it has been uncompressed, you can then untar it using the tar command above. (Alternatively, you can use gzip -d (for “decompress”) in place of gunzip.)
tar -czvf filename.tgz directoryname
This command, which uses a z switch (”zip”), allows you to take a bit of a shortcut instead of using the tar and gzip commands separately. The example will result in a compressed archive named filename.tgz.
tar -xzvf filename.tgz
This command is used to uncompress and extract the files from a .tgz archive.
Re: Common Unix/Linux Commands used via Telnet
An A-Z Index of the Bash command line for Linux.
[Only registered and activated users can see links. Click Here To Register...] Create an alias
apropos Search Help manual pages (man -k)
[Only registered and activated users can see links. Click Here To Register...] Search for and install software packages (Debian)
[Only registered and activated users can see links. Click Here To Register...] Spell Checker
[Only registered and activated users can see links. Click Here To Register...] Find and Replace text, database sort/validate/index
b
bash GNU Bourne-Again SHell
[Only registered and activated users can see links. Click Here To Register...] Arbitrary precision calculator language
[Only registered and activated users can see links. Click Here To Register...] Send to background
[Only registered and activated users can see links. Click Here To Register...] Exit from a loop
[Only registered and activated users can see links. Click Here To Register...] Run a shell builtin
[Only registered and activated users can see links. Click Here To Register...] Compress or decompress named file(s)
c
[Only registered and activated users can see links. Click Here To Register...] Display a calendar
[Only registered and activated users can see links. Click Here To Register...] Conditionally perform a command
[Only registered and activated users can see links. Click Here To Register...] Display the contents of a file
[Only registered and activated users can see links. Click Here To Register...] Change Directory
[Only registered and activated users can see links. Click Here To Register...] Partition table manipulator for Linux
[Only registered and activated users can see links. Click Here To Register...] Change group ownership
[Only registered and activated users can see links. Click Here To Register...] Change access permissions
[Only registered and activated users can see links. Click Here To Register...] Change file owner and group
[Only registered and activated users can see links. Click Here To Register...] Run a command with a different root directory
[Only registered and activated users can see links. Click Here To Register...] System services (runlevel)
[Only registered and activated users can see links. Click Here To Register...] Print CRC checksum and byte counts
clear Clear terminal screen
[Only registered and activated users can see links. Click Here To Register...] Compare two files
[Only registered and activated users can see links. Click Here To Register...] Compare two sorted files line by line
[Only registered and activated users can see links. Click Here To Register...] Run a command - ignoring shell functions
[Only registered and activated users can see links. Click Here To Register...] Resume the next iteration of a loop
[Only registered and activated users can see links. Click Here To Register...] Copy one or more files to another location
[Only registered and activated users can see links. Click Here To Register...] Daemon to execute scheduled commands
[Only registered and activated users can see links. Click Here To Register...] Schedule a command to run at a later time
[Only registered and activated users can see links. Click Here To Register...] Split a file into context-determined pieces
[Only registered and activated users can see links. Click Here To Register...] Divide a file into several parts
d
[Only registered and activated users can see links. Click Here To Register...] Display or change the date & time
[Only registered and activated users can see links. Click Here To Register...] Desk Calculator
[Only registered and activated users can see links. Click Here To Register...] Convert and copy a file, write disk headers, boot records
[Only registered and activated users can see links. Click Here To Register...] Data recovery tool
[Only registered and activated users can see links. Click Here To Register...] Declare variables and give them attributes
[Only registered and activated users can see links. Click Here To Register...] Display free disk space
[Only registered and activated users can see links. Click Here To Register...] Display the differences between two files
[Only registered and activated users can see links. Click Here To Register...] Show differences among three files
[Only registered and activated users can see links. Click Here To Register...] DNS lookup
[Only registered and activated users can see links. Click Here To Register...] Briefly list directory contents
[Only registered and activated users can see links. Click Here To Register...] Colour setup for `ls'
[Only registered and activated users can see links. Click Here To Register...] Convert a full pathname to just a path
[Only registered and activated users can see links. Click Here To Register...] Display list of remembered directories
[Only registered and activated users can see links. Click Here To Register...] Print kernel & driver messages
[Only registered and activated users can see links. Click Here To Register...] Estimate file space usage
e
[Only registered and activated users can see links. Click Here To Register...] Display message on screen
[Only registered and activated users can see links. Click Here To Register...] Search file(s) for lines that match an extended expression
[Only registered and activated users can see links. Click Here To Register...] Eject removable media
[Only registered and activated users can see links. Click Here To Register...] Enable and disable builtin shell commands
[Only registered and activated users can see links. Click Here To Register...] Environment variables
ethtool Ethernet card settings
[Only registered and activated users can see links. Click Here To Register...] Evaluate several commands/arguments
[Only registered and activated users can see links. Click Here To Register...] Execute a command
[Only registered and activated users can see links. Click Here To Register...] Exit the shell
[Only registered and activated users can see links. Click Here To Register...] Automate arbitrary applications accessed over a terminal
[Only registered and activated users can see links. Click Here To Register...] Convert tabs to spaces
[Only registered and activated users can see links. Click Here To Register...] Set an environment variable
[Only registered and activated users can see links. Click Here To Register...] Evaluate expressions
f
[Only registered and activated users can see links. Click Here To Register...] Do nothing, unsuccessfully
[Only registered and activated users can see links. Click Here To Register...] Low-level format a floppy disk
[Only registered and activated users can see links. Click Here To Register...] Partition table manipulator for Linux
[Only registered and activated users can see links. Click Here To Register...] Send job to foreground
[Only registered and activated users can see links. Click Here To Register...] Search file(s) for lines that match a fixed string
file Determine file type
[Only registered and activated users can see links. Click Here To Register...] Search for files that meet a desired criteria
[Only registered and activated users can see links. Click Here To Register...] Reformat paragraph text
[Only registered and activated users can see links. Click Here To Register...] Wrap text to fit a specified width.
[Only registered and activated users can see links. Click Here To Register...] Expand words, and execute commands
format Format disks or tapes
free Display memory usage
[Only registered and activated users can see links. Click Here To Register...] File system consistency check and repair
ftp File Transfer Protocol
[Only registered and activated users can see links. Click Here To Register...] Define Function Macros
[Only registered and activated users can see links. Click Here To Register...] Identify/kill the process that is accessing a file
g
[Only registered and activated users can see links. Click Here To Register...] Find and Replace text within file(s)
[Only registered and activated users can see links. Click Here To Register...] Parse positional parameters
[Only registered and activated users can see links. Click Here To Register...] Search file(s) for lines that match a given pattern
[Only registered and activated users can see links. Click Here To Register...] Print group names a user is in
[Only registered and activated users can see links. Click Here To Register...] Compress or decompress named file(s)
h
[Only registered and activated users can see links. Click Here To Register...] Remember the full pathname of a name argument
[Only registered and activated users can see links. Click Here To Register...] Output the first part of file(s)
[Only registered and activated users can see links. Click Here To Register...] Command History
[Only registered and activated users can see links. Click Here To Register...] Print or set system name
i
[Only registered and activated users can see links. Click Here To Register...] Print user and group id's
[Only registered and activated users can see links. Click Here To Register...] Conditionally perform a command
[Only registered and activated users can see links. Click Here To Register...] Configure a network interface
[Only registered and activated users can see links. Click Here To Register...] Stop a network interface
[Only registered and activated users can see links. Click Here To Register...] Start a network interface up
[Only registered and activated users can see links. Click Here To Register...] Capture an X server screen and save the image to file
[Only registered and activated users can see links. Click Here To Register...] Copy files and set attributes
j
[Only registered and activated users can see links. Click Here To Register...] Join lines on a common field
k
[Only registered and activated users can see links. Click Here To Register...] Stop a process from running
killall Kill processes by name
l
[Only registered and activated users can see links. Click Here To Register...] Display output one screen at a time
[Only registered and activated users can see links. Click Here To Register...] Perform arithmetic on shell variables
[Only registered and activated users can see links. Click Here To Register...] Make links between files
[Only registered and activated users can see links. Click Here To Register...] Create variables
[Only registered and activated users can see links. Click Here To Register...] Find files
[Only registered and activated users can see links. Click Here To Register...] Print current login name
[Only registered and activated users can see links. Click Here To Register...] Exit a login shell
[Only registered and activated users can see links. Click Here To Register...] Display lines beginning with a given string
[Only registered and activated users can see links. Click Here To Register...] Line printer control program
[Only registered and activated users can see links. Click Here To Register...] Off line print
lprint Print a file
lprintd Abort a print job
lprintq List the print queue
[Only registered and activated users can see links. Click Here To Register...] Remove jobs from the print queue
[Only registered and activated users can see links. Click Here To Register...] List information about file(s)
[Only registered and activated users can see links. Click Here To Register...] List open files
m
make Recompile a group of programs
[Only registered and activated users can see links. Click Here To Register...] Help manual
[Only registered and activated users can see links. Click Here To Register...] Create new folder(s)
[Only registered and activated users can see links. Click Here To Register...] Make FIFOs (named pipes)
mkisofs Create an hybrid ISO9660/JOLIET/HFS filesystem
[Only registered and activated users can see links. Click Here To Register...] Make block or character special files
[Only registered and activated users can see links. Click Here To Register...] Display output one screen at a time
[Only registered and activated users can see links. Click Here To Register...] Mount a file system
[Only registered and activated users can see links. Click Here To Register...] Manipulate MS-DOS files
[Only registered and activated users can see links. Click Here To Register...] Move or rename files or directories
[Only registered and activated users can see links. Click Here To Register...] Mass Move and rename (files)
n
netstat Networking information
[Only registered and activated users can see links. Click Here To Register...] Set the priority of a command or job
[Only registered and activated users can see links. Click Here To Register...] Number lines and write files
[Only registered and activated users can see links. Click Here To Register...] Run a command immune to hangups
[Only registered and activated users can see links. Click Here To Register...] Query Internet name servers interactively
o
[Only registered and activated users can see links. Click Here To Register...] Open a file in its default application
[Only registered and activated users can see links. Click Here To Register...] Operator access
p
[Only registered and activated users can see links. Click Here To Register...] Modify a user password
[Only registered and activated users can see links. Click Here To Register...] Merge lines of files
pathchk Check file name portability
[Only registered and activated users can see links. Click Here To Register...] Test a network connection
[Only registered and activated users can see links. Click Here To Register...] Stop processes from running
[Only registered and activated users can see links. Click Here To Register...] Restore the previous value of the current directory
[Only registered and activated users can see links. Click Here To Register...] Prepare files for printing
printcap Printer capability database
printenv Print environment variables
[Only registered and activated users can see links. Click Here To Register...] Format and print data
[Only registered and activated users can see links. Click Here To Register...] Process status
[Only registered and activated users can see links. Click Here To Register...] Save and then change the current directory
[Only registered and activated users can see links. Click Here To Register...] Print Working Directory
q
[Only registered and activated users can see links. Click Here To Register...] Display disk usage and limits
[Only registered and activated users can see links. Click Here To Register...] Scan a file system for disk usage
[Only registered and activated users can see links. Click Here To Register...] Set disk quotas
r
[Only registered and activated users can see links. Click Here To Register...] ram disk device
[Only registered and activated users can see links. Click Here To Register...] Copy files between two machines
[Only registered and activated users can see links. Click Here To Register...] read a line from standard input
[Only registered and activated users can see links. Click Here To Register...] Mark variables/functions as readonly
reboot Reboot the system
renice Alter priority of running processes
remsync Synchronize remote files via email
[Only registered and activated users can see links. Click Here To Register...] Exit a shell function
[Only registered and activated users can see links. Click Here To Register...] Reverse lines of a file
[Only registered and activated users can see links. Click Here To Register...] Remove files
[Only registered and activated users can see links. Click Here To Register...] Remove folder(s)
[Only registered and activated users can see links. Click Here To Register...] Remote file copy (Synchronize file trees)
s
[Only registered and activated users can see links. Click Here To Register...] Multiplex terminal, run remote shells via ssh
[Only registered and activated users can see links. Click Here To Register...] Secure copy (remote file copy)
[Only registered and activated users can see links. Click Here To Register...] Merge two files interactively
[Only registered and activated users can see links. Click Here To Register...] Stream Editor
[Only registered and activated users can see links. Click Here To Register...] Accept keyboard input
[Only registered and activated users can see links. Click Here To Register...] Print numeric sequences
[Only registered and activated users can see links. Click Here To Register...] Manipulate shell variables and functions
sftp Secure File Transfer Program
[Only registered and activated users can see links. Click Here To Register...] Shift positional parameters
[Only registered and activated users can see links. Click Here To Register...] Shell Options
[Only registered and activated users can see links. Click Here To Register...] Shutdown or restart linux
[Only registered and activated users can see links. Click Here To Register...] Delay for a specified time
[Only registered and activated users can see links. Click Here To Register...] Find files
[Only registered and activated users can see links. Click Here To Register...] Sort text files
[Only registered and activated users can see links. Click Here To Register...] Run commands from a file `.'
[Only registered and activated users can see links. Click Here To Register...] Split a file into fixed-size pieces
[Only registered and activated users can see links. Click Here To Register...] Secure Shell client (remote login program)
strace Trace system calls and signals
[Only registered and activated users can see links. Click Here To Register...] Substitute user identity
[Only registered and activated users can see links. Click Here To Register...] Execute a command as another user
[Only registered and activated users can see links. Click Here To Register...] Print a checksum for a file
[Only registered and activated users can see links. Click Here To Register...] Make a new name for a file
[Only registered and activated users can see links. Click Here To Register...] Synchronize data on disk with memory
t
[Only registered and activated users can see links. Click Here To Register...] Output the last part of files
[Only registered and activated users can see links. Click Here To Register...] Tape ARchiver
[Only registered and activated users can see links. Click Here To Register...] Redirect output to multiple files
[Only registered and activated users can see links. Click Here To Register...] Evaluate a conditional expression
[Only registered and activated users can see links. Click Here To Register...] Measure Program running time
[Only registered and activated users can see links. Click Here To Register...] User and system times
[Only registered and activated users can see links. Click Here To Register...] Change file timestamps
[Only registered and activated users can see links. Click Here To Register...] List processes running on the system
[Only registered and activated users can see links. Click Here To Register...] Trace Route to Host
trap Run a command when a signal is set(bourne)
[Only registered and activated users can see links. Click Here To Register...] Translate, squeeze, and/or delete characters
[Only registered and activated users can see links. Click Here To Register...] Do nothing, successfully
[Only registered and activated users can see links. Click Here To Register...] Topological sort
[Only registered and activated users can see links. Click Here To Register...] Print filename of terminal on stdin
[Only registered and activated users can see links. Click Here To Register...] Describe a command
u
[Only registered and activated users can see links. Click Here To Register...] Limit user resources
[Only registered and activated users can see links. Click Here To Register...] Users file creation mask
umount Unmount a device
[Only registered and activated users can see links. Click Here To Register...] Remove an alias
[Only registered and activated users can see links. Click Here To Register...] Print system information
[Only registered and activated users can see links. Click Here To Register...] Convert spaces to tabs
[Only registered and activated users can see links. Click Here To Register...] Uniquify files
[Only registered and activated users can see links. Click Here To Register...] Convert units from one scale to another
[Only registered and activated users can see links. Click Here To Register...] Remove variable or function names
[Only registered and activated users can see links. Click Here To Register...] Unpack shell archive scripts
[Only registered and activated users can see links. Click Here To Register...] Execute commands (until error)
[Only registered and activated users can see links. Click Here To Register...] Create new user account
[Only registered and activated users can see links. Click Here To Register...] Modify user account
[Only registered and activated users can see links. Click Here To Register...] List users currently logged in
[Only registered and activated users can see links. Click Here To Register...] Encode a binary file
[Only registered and activated users can see links. Click Here To Register...] Decode a file created by uuencode
v
v Verbosely list directory contents (`ls -l -b')
vdir Verbosely list directory contents (`ls -l -b')
[Only registered and activated users can see links. Click Here To Register...] Text Editor
[Only registered and activated users can see links. Click Here To Register...] Report virtual memory statistics
w
[Only registered and activated users can see links. Click Here To Register...] Execute/display a program periodically
[Only registered and activated users can see links. Click Here To Register...] Print byte, word, and line counts
[Only registered and activated users can see links. Click Here To Register...] Report all known instances of a command
[Only registered and activated users can see links. Click Here To Register...] Locate a program file in the user's path.
[Only registered and activated users can see links. Click Here To Register...] Execute commands
[Only registered and activated users can see links. Click Here To Register...] Print all usernames currently logged in
[Only registered and activated users can see links. Click Here To Register...] Print the current user id and name (`id -un')
Wget Retrieve web pages or files via HTTP, HTTPS or FTP
[Only registered and activated users can see links. Click Here To Register...] Send a message to another user
x
[Only registered and activated users can see links. Click Here To Register...] Execute utility, passing constructed argument list(s)
[Only registered and activated users can see links. Click Here To Register...] Print a string until interrupted
[Only registered and activated users can see links. Click Here To Register...] Run a command script in the current shell
[Only registered and activated users can see links. Click Here To Register...] Comment / Remark
Re: Common Unix/Linux Commands used via Telnet
Useful Telnet and CLI commands for Dm and Linux servers
When you Telnet your box or make a SSH connection shell to your Linux server, these commands are useful for you:
1-Show me who is online, which IP and which Gbox Version is running:
cat /var/tmp/share.onl
2- Show me all Distance 1 cards:
grep "dist:1" /var/tmp/share.info
3- Show me all Distance 1 cards and resolve the Provider ID:
for i in `grep 'dist:1' /var/tmp/share.info | awk '{print $6}' | sort` ; do grep "^$i" /var/keys/ident.info ; done
4-remove the Windows carriage returns ^M on Textfiles:
tr -s "\r" "\n" < winfile > unixfile
5-Showing the ident.info file in a nice way:
first CD to /var/keys
then:
cat ident.info | cut -c 1-9,19-196 > ident.info.new
and you will see the providers lije this example:
01000000;S0 - Mediaguard CAID
01000002;(Old)S1 - Orbit (1W/26E)
01000003;(Old)S1 - Canal+ France (19E)
6-With this command, you can also see if gbox process is running:
ps -ef
7- To start cs2gbox:
cd /var/bin/
./cs2gbox &
8- To start gbox:
cd /var/bin/
./gbox&
9- To start cs2gbox and gbox together in Gemini:
/var/script/gbox_cam.sh start
10-To stop cs2gbox:
killall cs2gbox
11- To stop gbox:
killall gbox
12- To chmod binary:
chmod 755 <filename>
13- To see number of cards from a peer :
cd /tmp/
grep <peer domain> share.info | wc -l
14- To see cards from a peer with distance and level:
cd /tmp/
grep <peer domain> share.info
15- To see peer status:
cd /tmp/
more share.onl
(Lines beginning with 1 are online peers, Lines beginning with 0 are offline peers)
16- To see number of cards with level X where X = number
cd /tmp/
grep Lev:X share.info | wc -l
17- To see number of cards with level X for a certain peer where X = number
cd /tmp/
grep <peer domain> share.info | grep Lev:X | wc -l
18- To see number of cards at distance X where X = number
cd /tmp/
grep dist:X share.info | wc -l
19- To see number of cards with distance X for a certain peer where X = number
cd /tmp/
grep <peer domain> share.info | grep dist:X | wc -l
20-rebooting your server:
reboot
21- changing your server login password (Very important):
passwd
22-For editing files:
vi <filename}
example:
vi /var/keys/cwshare.cfg
Re: Common Unix/Linux Commands used via Telnet
Ban cccam users in iptables
Here is a little command to get formated iptable rules to ban deleted cccam users:
cat /var/log/cccam.warn | awk '{printf "-A INPUT -s %s -j REJECT \n", $5}' | awk 'x[$0]++ == 0'
the cccam.warn file is from "LOG WARNINGS" parameter in CCcam.cfg .
in CCcam.cfg:
LOG WARNINGS : /var/log/cccam.warn
touch /var/log/cccam.warn