07-03-2014  (2197 ) Categoria: Articles

Linux Commands

 

gvfs-set-attribute /path/to/folder metadata::custom-icon file:///path/to/image


Command Description
cat [filename] Display file’s contents to the standard output device (usually your monitor).
cd /directorypath Change to directory.
chmod [options] mode filename Change a file’s permissions.
chown [options] filename Change who owns a file.
clear Clear a command line screen/window for a fresh start.
cp [options] source destination Copy files and directories.
date [options] Display or set the system date and time.
df [options] Display used and available disk space.
du [options] Show how much space each file takes up.
file [options] filename Determine what type of data is within a file.
find [pathname] [expression] Search for files matching a provided pattern.
grep [options] pattern [filesname] Search files or output for a particular pattern.
kill [options] pid Stop a process. If the process refuses to stop, use kill -9 pid.
less [options] [filename] View the contents of a file one page at a time.
ln [options] source [destination] Create a shortcut.
locate filename Search a copy of your filesystem for the specified filename.
lpr [options] Send a print job.
ls [options] List directory contents.
man [command] Display the help information for the specified command.
mkdir [options] directory Create a new directory.
mv [options] source destination Rename or move file(s) or directories.
passwd [name [password]] Change the password or allow (for the system administrator) to change any password.
ps [options] Display a snapshot of the currently running processes.
pwd Display the pathname for the current directory.
rm [options] directory Remove (delete) file(s) and/or directories.
rmdir [options] directory Delete empty directories.
ssh [options] user@machine Remotely log in to another Linux machine, over the network. Leave an ssh session by typing exit.
su [options] [user [arguments]] Switch to another user account.
tail [options] [filename] Display the last n lines of a file (the default is 10).
tar [options] filename Store and extract files from a tarfile (.tar) or tarball (.tar.gz or .tgz).
top Displays the resources being used on your system. Press q to exit.
touch filename Create an empty file with the specified name.
who [options] Display who is logged on.

 

-sudo permission

Linux Command Quick Reference

The following list describes some of the most useful and popular Linux commands. Consult the man page for each command to learn about additional arguments and details of operation.

adduser userid

Creates a new userid, prompting for necessary information (requires root privileges).

apropos keyword

Searches the manual pages for occurrences of the specified keyword and prints short descriptions from the beginning of matching manual pages.

at time
at -f file time

Executes commands entered via stdin (or, by using the alternative form, the specified file) at the specified time. The time can be specified in a variety of ways; for example, in hour and minute format hh: mm or in hour, minute, month, day, and year format hh: mm mm/ dd/ yy.

atq

Prints descriptions of jobs pending via the at command.

atrm job

Cancels execution of a job scheduled via the at command. Use the atq command to discover the identities of scheduled jobs.

bg
bg jobs

Places the current job (or, by using the alternative form, the specified jobs) in the background, suspending its execution so that a new user prompt appears immediately. Use the jobs command to discover the identities of background jobs.

cal month year

Prints a calendar for the specified month of the specified year.

cat files

Prints the contents of the specified files.

cd
cd directory

Changes the current working directory to the user's home directory or the specified directory.

chgrp group files
chgrp -R group files

Changes the group of the specified files to the specified group. The alternative form of the command operates recursively, changing the group of subdirectories and files beneath a specified directory. The group must be named in the /etc/groups file, maintained by the newgroup command.

chmod mode files
chmod -R mode files

Changes the access mode of the specified files to the specified mode. The alternative form of the command operates recursively, changing the mode of subdirectories and files beneath a specified directory.

chown userid files
chown -R userid files

Changes the owner of the specified files to the specified userid. The alternative form of the command operates recursively, changing the owner of subdirectories and files beneath a specified directory

clear

Clears the terminal screen.

cmp file1 file2

Compares two files, reporting all discrepancies. Similar to the diff command, though the output format differs.

cp file1 file2
cp files directory
cp -R files directory

Copies a file to another file or directory, or copies a subdirectory and all its files to another directory.

date
date date

Displays the current date and time or changes the system date and time to the specified value, of the form MMddhhmmyy or MMddhhmmyyyy.

df

Prints the amount of free disk space on each mounted filesystem.

diff file1 file2

Compares two files, reporting all discrepancies. Similar to the cmp command, though the output format differs.

dmesg

Prints the messages resulting from the most recent system boot.

du
du directories

Prints the amount of disk space used by the current directory (or the specified directories) and its (their) subdirectories.

echo string
echo -n string

Prints the specified text on the standard output stream. The -n option causes omission of the trailing newline character.

fdformat device

Formats the media inserted in the specified floppy disk drive. The command performs a low-level format only; it does not create a filesystem. To create a filesystem, issue the mkfs command after formatting the media.

fdisk device

Edits the partition table of the specified hard disk.

fg
fg jobs

Brings the current job (or the specified jobs) to the foreground.

file files

Determines and prints a description of the type of each specified file.

find path -name pattern -print

Searches the specified path for files with names matching the specified pattern (usually enclosed in single quotes) and prints their names. The find command has many other arguments and functions; see the online documentation.

finger users

Prints descriptions of the specified users.

free

Displays the amount of used and free system memory.

ftp hostname

Opens an FTP connection to the specified host, allowing files to be transferred. The FTP program provides subcommands for accomplishing file transfers; see the online documentation.

grep pattern files
grep -i pattern files
grep -n pattern files
grep -v pattern files

Search the specified files for text matching the specified pattern (usually enclosed in single quotes) and print matching lines. The -i option specifies that matching is performed without regard to case. The -n option specifies that each line of output is preceded by the file name and line number. The -v option reverses the matching, causing non-matched lines to be printed.

gzip files
gunzip files

Compress (or expand) the specified files. Generally, a compressed file has the same name as the original file, followed by . gz.

head files

Prints the first several lines of each specified file.

hostname
hostname name

Displays (or sets) the name of the host.

info

Launches the GNU Texinfo help system.

init run_level

Changes the system run level to the specified value (requires root privileges).

insmod module

Dynamically loads the specified module (requires root privileges).

jobs

Displays all background jobs.

ispell files

Checks the spelling of the contents of the specified files.

kill process_ids
kill - signal process_ids
kill -l

Kills the specified processes, sends the specified processes the specified signal (given as a number or name), or prints a list of available signals.

killall program
killall - signal program

Kills all processes that are instances of the specified program or sends the specified signal to all processes that are instances of the specified program.

ln old new
ln -s old new

Creates a hard (or soft) link associating a new name with an existing file or directory.

locate pattern

Locates files with names containing the specified pattern. Uses the database maintained by the updatedb command.

lpq

Prints the entries of the print queue.

lpr files

Prints the specified files.

lprm job

Cancels printing of the specified print queue entries. Use lpq to determine the contents of the print queue.

ls
ls files
ls -a files
ls -l files
ls -lR files

Lists (non-hidden) files in the current directory or the specified files or directories. The -a option lists hidden files as well has non-hidden files. The -l option causes the list to include descriptive information, such as file size and modification date. The -R option recursively lists the subdirectories of the specified directories.

mail

Launches a simple mail client that permits sending and receiving email messages.

man title
man section title

Prints the specified man page.

mkdir directories
mkdir -p directories

Creates the specified directories. The -p option causes creation of any parent directories needed to create a specified directory.

mkfs -t type device

Creates a file system of the specified type (such as ext2 or msdos) on the specified device (requires root privileges).

mkswap device

Creates a Linux swap space on the specified hard disk partition (requires root privileges).

more file

Lets the user peruse a file too large to be displayed as a single screen (page) of output. The more command provides many subcommands that let the user navigate the file. For example, the Space key moves forward one page, the b key moves back one page, and the q key exits the program.

mount
mount device directory
mount -o option -t type device directory

Prints the mounted devices or mounts the specified device at the specified mount point (generally a subdirectory of /mnt). The mount command consults /etc/fstab to determine standard options associated with a device. The command generally requires root privileges. The -o option allows specification of a variety of options; for example, ro for read-only access. The -t option allows specification of the filesystem type (for example, ext2, msdos, or iso9660, the filesystem type generally used for CD-ROMs).

mv paths target

Moves the specified files or directories to the specified target.

newgroup group

Creates the specified group.

passwd
passwd user

Changes the current user's password, or that of the specified user (requires root privileges). The command prompts for the new password.

ping host

Sends an echo request via TCP/IP to the specified host. A response confirms that the host is operational.

pr files

Formats the specified files for printing, by inserting page breaks and so on. The command provides many arguments and functions.

ps
ps -Aux

Displays the processes associated with the current userid or displays a description of each process.

pwd

Prints the absolute path corresponding to the current working directory.

reboot

Reboots the system (requires root privileges).

reset

Clears the terminal screen and resets the terminal status.

rm files
rm -i files
rm -f files
rm -if files
rm -rf files

Deletes the specified files or (when the -r option is specified) recursively deletes all subdirectories of the specified files and directories. The -i option causes the command to prompt for confirmation; the -f option suppresses confirmation. Because deleted files cannot generally be recovered, the -f option should be used only with extreme care, particularly when used by the root user.

rmdir directories
rmdir -p directories

Deletes the specified empty directories or (when the -p option is specified) the empty directories along the specified path.

shutdown minutes
shutdown -r minutes

Shuts down the system after the specified number of minutes elapses (requires root privileges). The -r option causes the system to be rebooted once it has shut down.

sleep time

Causes the command interpreter to pause for the specified number of seconds.

sort files

Sorts the specified files. The command has many useful arguments; see the online documentation.

split file

Splits a file into several smaller files. The command has many arguments; see the online documentation.

su
su user
su -
su - user

Changes the current userid to root or to the specified userid (the latter requires root privileges). The - option establishes a default environment for the new userid.

swapon device

Enables use of the specified device for swapping (requires root privileges).

swapoff device

Disables use of the specified device for swapping (requires root privileges).

sync

Completes all pending input/output operations (requires root privileges).

tail file
tail - n file
tail -f file

Prints the last several lines of the specified files. The -n option specifies the number of lines to be printed. The -f option causes the command to continuously print additional lines as they are written to the file.

talk user

Launches a program that allows a chat-like dialog with the specified user.

tar cvf tar_file files
tar zcvf tar_file files

Creates a tar file with the specified name, containing the specified files and their subdirectories. The z option specified that the tar file will be compressed.

tar xvf tar_file
tar zxvf tar_file

Extracts the contents of the specified tar file. The z option specified that the tar file has been compressed.

telnet host

Opens a login session on the specified host.

top

Prints a display of system processes that's continually updated until the user presses the q key.

traceroute host

Uses echo requests to determine and print a network path to the host.

umount device

Unmounts the specified filesystem (generally requires root privileges).

uptime

Prints the system uptime.

w

Prints the current system users.

wall

Prints a message to each user except those who've disabled message reception. Type Ctrl-D to end the message.

wc files

Prints the number of characters, words, and lines in the specified files.

Table E.1 identifies Linux commands that perform functions similar to MS-DOS commands. The operation of the Linux command is not generally identical to that of the corresponding MS-DOS command. See the index to this book or the Linux online documentation for further information about Linux commands.

 

Table E.1: MS-DOS Commands and Related Linux Commands

MS-DOS

Linux

ATTRIB

chmod

CD

cd

CHKDSK

df, du

DELTREE

rm -R

DIR

ls -l

DOSKEY

(built-in; no need to launch separately)

EDIT

ae, vi, and so on

EXTRACT

tar

FC

cmp, diff

FDISK

fdisk

FIND

grep

FORMAT

fdformat

MORE

more

MOVE

mv

SORT

sort

START

at, bg

XCOPY, XCOPY32

cp

 

Command Description
a2p Creates a Perl script from an awk script.
ac Prints statistics about users' connect time.
access Checks real user's permissions for a file.
agrep Version of the grep utility which also matches approximate patterns.
alias Create a name for another command or long command string.
apropos Searches the manual pages for a keyword or regular expression.
apt-cache Queries the APT software package cache.
apt-get Command line tool for working with APT software packages.
aptitude Text-based front-end for the APT package management system.
ar Maintain portable archive or library.
arch Display the architecture of the current host.
arp Manipulate the system ARP cache.
as An assembler.
aspell Interactive spell checker.
at Command scheduler.
awk Awk script processing program.
basename Deletes any specified prefix from a string.
bash Command Bourne interpreter
bc Calculator.
bdiff Compare large files.
bfs Editor for large files.
bg Continues a program running in the background.
biff Enable and disable incoming mail notifications.
break Break out of while, for, foreach, or until loop.
bs Battleship game.
bye Alias often used for the exit command.
cal Calendar.
calendar Display appointments and reminders.
cancel Cancels a print job.
cat View or modify a file.
cc C compiler.
cd Change directory.
chdir Change directory.
checkeq Language processors to assist in describing equations.
checknr Check nroff and troff files for any errors.
chfn Modify your own information or if super user or root modify another users information.
chgrp Change a groups access to a file or directory.
chkey Change the secure RPC key pair.
chmod Change the permission of a file.
chown Change the ownership of a file.
chroot Run a command or shell from another directory, and treats that directory as root.
chsh Change login shell.
cksum Display and calculate a CRC for files.
clear Clears screen.
cls Alias often used to clear a screen.
cmp Compare files.
col Reverse line-feeds filter.
comm Compare files and select or reject lines that are common.
compress Compress files on a computer.
continue Break out of while, for, foreach, or until loop.
copy Copy files.
cp Copy files.
cpio Creates archived CPIO files.
crontab Create and list files that you wish to run on a regular schedule.
crypt Function used to encrypt passwords.
csh Execute the C shell command interpreter
csplit Split files based on context.
ctags Create a tag file for use with ex and vi.
cu Calls or connects to another Unix system, terminal or non-Unix system.
curl Transfer a URL.
cut Cut out selected fields of each line of a file.
date Tells you the date and time in Unix.
dc An arbitrary precision arithmetic package.
dd Convert and copy a file.
df Display the available disk space for each mount.
depmod Generates a list of kernel module dependences, modules.dep, and associated map files.
deroff Removes nroff/troff, tbl, and eqn constructs.
dhclient Dynamic Host Configuration Protocol Client.
diff Displays two files and prints the lines that are different.
dig DNS lookup utility.
dircmp Lists the different files when comparing directories.
dirname Deliver portions of path names.
dmesg Print or control the kernel ring buffer.
dos2unix Converts text files between DOS and Unix formats.
dpkg Queries, installs, removes, and maintains Debian software packages and their dependencies.
dpost Translates files created by troff into PostScript.
du Tells you how much space a file occupies.
echo Displays text after echo to the terminal.
ed Line oriented file editor.
edit Text editor.
egrep Search a file for a pattern using full regular expressions.
eject Ejects removable media.
elm Program command used to send and receive e-mail.
emacs Text editor.
enable Enables and disables LP printers.
env Displays environment variables.
eqn Language processors to assist in describing equations.
ex Line-editor mode of the vi text editor.
exit Exit from a program, shell or log you out of a Unix network.
expand Expand copies of file s.
expr Evaluate arguments as an expression.
fc The FC utility lists or edits and re-executes, commands previously entered to an interactive sh.
fg Continues a stopped job by running it in the foreground
fgrep Search a file for a fixed-character string.
file Tells you if the object you are looking at is a file or if it is a directory.
find Finds one or more files assuming that you know their approximate filenames.
findsmb List info about machines that respond to SMB name queries on a subnet.
finger Lists information about the user.
fmt Simple text formatters.
fold Filter for folding lines.
for Shell built-in functions to repeatedly execute action(s) for a selected number of times.
foreach Shell built-in functions to repeatedly execute action(s) for a selected number of times.
free Display amount of free and used memory in the system
fromdos Converts text files between DOS and Unix formats.
fsck Check and repair a Linux file system.
ftp Enables ftp access to another terminal.
fuser Identify processes using files or sockets.
gawk Powerful pattern-matching and processing language.
getfacl Display discretionary file information.
gethostname System call to get the hostname of the current processor.
gpasswd Administer /etc/group and /etc/gshadow.
gprof The gprof utility produces an execution profile of a program.
grep Finds text within a file.
groupadd Creates a new group account.
groupdel Enables a super user or root to remove a group.
groupmod Enables a super user or root to modify a group.
gunzip Expand compressed files.
gview A programmers text editor.
gvim A programmers text editor.
gzip Compress files.
halt Stop the computer.
hash Remove internal hash table.
hashstat Display the hash stats.
head Displays the first ten lines of a file, unless otherwise stated.
help If computer has online help documentation installed this command will display it.
history Display the history of commands typed.
host DNS lookup utility.
hostid Prints the numeric identifier for the current host.
hostname Set or print name of current host system.
id Shows you the numeric user and group ID on BSD.
ifconfig Sets up network interfaces.
ifdown Take a network interface down.
ifup Bring a network interface up.
info Read Info documents.
init Process control initialization.
iostat Reports Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
ip Show and manipulate routing, devices, policy routing and tunnels.
isalist Display the native instruction sets executable on this platform.
iwconfig Configure a wireless network interface.
jobs List the jobs currently running in the background.
join Joins command forms together.
keylogin Decrypt the user's secret key.
kill Cancels a job.
killall Kills processes by name.
ksh Korn shell command interpreter.
ld Link-editor for object files.
ldd List dynamic dependencies of executable files or shared objects.
less Opposite of the more command.
lex Generate programs for lexical tasks.
link Calls the link function to create a link to a file.
ln Creates a link to a file.
lo Allows you to exit from a program, shell or log you out of a Unix network.
locate List files in databases that match a pattern.
login Signs into a new system.
logname Returns users login name.
logout Logs out of a system.
losetup Sets up and controls loop devices.
lp Prints a file on System V systems.
lpadmin Configure the LP print service.
lpc Line printer control program.
lpq Lists the status of all the available printers.
lpr Submits print requests.
lprm Removes print requests from the print queue.
lpstat Lists status of the LP print services.
ls Lists the contents of a directory.
lsof Lists open files.
lzcat View compressed .lzma files.
lzma Compress files to .lzma file.
mach Display the processor of the current host.
mail One of the ways that allows you to read/send E-Mail.
mailcompat Provide SunOS 4.x compatibility for the Solaris mailbox format.
mailx Mail interactive message processing system.
make Executes a list of shell commands associated with each target.
man Display a manual of a command.
mesg Control if non-root users can send text messages to you.
mii-tool View, manipulate media-independent interface status.
mkdir Create a directory.
mkfs Build a Linux file system, usually a hard disk partition.
modprobe Adds and removes modules from the linux kernel.
more Displays text one screen at a time.
mount Creates a file systems and remote resources.
mt Magnetic tape control.
mv Renames a file or moves it from one directory to another directory.
nc TCP/IP swiss army knife.
neqn Language processors to assist in describing equations.
netstat Shows network status.
newalias Install new elm aliases for user or system.
newform Change the format of a text file.
newgrp Log into a new group.
nice Invokes a command with an altered scheduling priority.
niscat Display NIS+ tables and objects.
nischmod Change access rights on a NIS+ object.
nischown Change the owner of a NIS+ object.
nischttl Change the time to live value of a NIS+ object.
nisdefaults Display NIS+ default values.
nisgrep Utilities for searching NIS+ tables.
nismatch Utilities for searching NIS+ tables.
nispasswd Change NIS+ password information.
nistbladm NIS+ table administration command.
nl Get the numbers the lines in a file.
nmap Network exploration tool and security port scanner.
nohup Runs a command even if the session is disconnected or the user logs out.
nroff Formats documents for display or line-printer.
nslookup Queries a name server for a host or domain lookup.
od Dump files in octal and other formats.
on Execute a command on a remote system, but with the local environment.
onintr Shell built-in functions to respond to (hardware) signals.
optisa Determine which variant instruction set is optimal to use.
pack Shrinks file into a compressed file.
pagesize Display the size of a page of memory in bytes, as returned by getpagesize.
passwd Allows you to change your password.
paste Merge corresponding or subsequent lines of files.
pax Read/write and writes lists of the members of archive files and copy directory hierarchies.
pcat Compresses file.
perl Perl is a programming language optimized for scanning arbitrary text files, extracting information from those text files.
pg Files perusal filters for CRTs.
pgrep Examine the active processes on the system and reports the process IDs of the processes
pico Simple and very easy to use text editor in the style of the Pine Composer.
pine Command line program for Internet News and Email.
ping Sends ICMP ECHO_REQUEST packets to network hosts.
pkill Examine the active processes on the system and reports the process IDs of the processes
poweroff Stop the computer.
pr Formats a file to make it look better when printed.
priocntl Display's or set scheduling parameters of specified process(es)
printenv Prints all or part of environment.
printf Write formatted output.
ps Reports the process status.
pstree Displays processes in tree format.
pvs Display the internal version information of dynamic objects within an ELF file.
pwd Print the current working directory.
quit Allows you to exit from a program, shell or log you out of a Unix network.
rcp Copies files from one computer to another computer.
readlink Prints the value of a symbolic link or canonical file name.
reboot Stop the computer.
red Line oriented file editor.
rehash Recomputes the internal hash table of the contents of directories listed in the path.
remsh Runs a command on another computer.
renice Alters the priority of running processes.
repeat Shell built-in functions to repeatedly execute action(s) for a selected number of times.
replace A string-replacement utility.
rgview A programmers text editor.
rgvim A programmers text editor.
rlogin Establish a remote connection from your terminal to a remote machine.
rm Deletes a file without confirmation (by default).
rmail One of the ways that allows you to read/send E-Mail.
rmdir Deletes a directory.
rn Reads newsgroups.
route Show and manipulate the IP routing table.
rpcinfo Report RPC information.
rsh Runs a command on another computer.
rsync Faster, flexible replacement for rcp.
rview A programmers text editor.
rvim A programmers text editor.
s2p Convert a sed script into a Perl script.
sag Graphically displays the system activity data stored in a binary data file by a previous sar run.
sar Displays the activity for the CPU.
screen Screen manager with VT100/ANSI terminal emulation.
script Records everything printed on your screen.
sdiff Compares two files, side-by-side.
sed Allows you to use pre-recorded commands to make changes to text.
sendmail Sends mail over the Internet.
service Runs a System V init script.
set Set the value of an environment variable.
setenv Set the value of an environment variable.
setfacl Modify the Access Control List (ACL) for a file or files.
sethostname System calls or set the hostname of the current processor.
settime Change file access and modification time.
sftp Secure file transfer program.
sh Runs or processes jobs through the Bourne shell.
shred Delete a file securely, first overwriting it to hide its contents.
shutdown Turn off the computer immediately or at a specified time.
sleep Waits a x amount of seconds.
slogin OpenSSH SSH client (remote login program).
smbclient An ftp-like client to access SMB/CIFS resources on servers.
sort Sorts the lines in a text file.
spell Looks through a text file and reports any words that it finds in the text file that are not in the dictionary.
split Split a file into pieces.
stat Display file or filesystem status.
stop Control process execution.
strftime Formats strings that represent the system date and time.
strip Discard symbols from object files.
stty Sets options for your terminal.
su Become super user or another user.
sysinfo Get and set system information strings.
sysklogd Linux system logging utilities.
tabs Set tabs on a terminal.
tail Delivers the last part of the file.
talk Talk with other logged in users.
tac Concatenate and print files in reverse.
tar Create tape archives and add or extract files.
tbl Preprocessor for formatting tables for nroff or troff.
tcopy Copy a magnetic tape.
tcpdump Dump traffic on a network.
tee Read from an input and write to a standard output or file.
telinit Process control initialization.
telnet Uses the telnet protocol to connect to another remote computer.
test Check file types and compare values.
time Used to time a simple command.
timex The timex command times a command; reports process data and system activity.
todos Converts text files between DOS and Unix formats.
top Display Linux tasks.
touch Change file access and modification time.
tput Initialize a terminal or query terminfo database.
tr Translate characters.
traceroute Print the route packets take to network host.
troff Typeset or format documents.
tty Print the file name of the terminal connected to standard input.
ul Reads the named filenames or terminal and does underlining.
umask Get or set the file mode creation mask.
unalias Remove an alias.
unhash Remove internal hash table.
uname Print name of current system.
uncompress Uncompressed compressed files.
uniq Report or filter out repeated lines in a file.
unlink Call the unlink function to remove the specified file.
unlzma Decompress .lzma file.
unmount Disconnects a file systems and remote resources.
unpack Expands a compressed file.
untar Create tape archives and add or extract files.
until Execute a set of actions while/until conditions are evaluated TRUE.
unxz Decompress .xz files.
unzip List, test and extract compressed files in a ZIP archive.
useradd Create a new user or updates default new user information.
userdel Remove a users account.
usermod Modify a users account.
vacation Reply to mail automatically.
vedit Screen-oriented (visual) display editor based on ex.
vgrind Grind nice program listings
vi Screen-oriented (visual) display editor based on ex.
vim A programmers text editor.
view A programmers text editor.
w Show who is logged on and what they are doing.
wait Await process completion.
wall Send a message to everybody's terminal.
wc Displays a count of lines, words, and characters in a file
whatis Displays short manual page descriptions.
whereis Locate a binary, source, and manual page files for a command.
while Repetitively execute a set of actions while/until conditions are evaluated TRUE.
which Locate a command.
who Displays who is on the system.
whoami Print effective userid.
whois Internet user name directory service.
write Send a message to another user.
X Execute the X windows system.
xfd Display all the characters in an X font.
xhost Server access control program for X.
xlsfonts Server font list displayer for X.
xset User preference utility for X.
xterm Terminal emulator for X.
xrdb X server resource database utility.
xz Compress files to .xz files.
xzcat View compressed .xz files.
yacc Short for yet another compiler-compiler, yacc is a compiler.
yes Repeatedly output a line with all specified STRING(s), or 'y'.
yppasswd Changes network password in the NIS database.
yum Interactive rpm based package manager.
zcat Compress files.
zip Compression and file packaging utility.

__________________________________

NAME

       rename - renames multiple files

SYNOPSIS

       rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

DESCRIPTION

       "rename" renames the filenames supplied according to the rule specified
       as the first argument.  The perlexpr argument is a Perl expression
       which is expected to modify the $_ string in Perl for at least some of
       the filenames specified.  If a given filename is not modified by the
       expression, it will not be renamed.  If no filenames are given on the
       command line, filenames will be read via standard input.

       For example, to rename all files matching "*.bak" to strip the
       extension, you might say

               rename ’s/.bak$//’ *.bak

       To translate uppercase names to lower, you’d use

               rename ’y/A-Z/a-z/’ *

OPTIONS

       -v, --verbose
               Verbose: print names of files successfully renamed.

       -n, --no-act
               No Action: show what files would have been renamed.

       -f, --force
               Force: overwrite existing files.

________________________________________

Very easily to rename all the files in the current directory you can type (assuming you are using bash):

for i in *; do mv $i 1_$i; done

obviously take it with care (it will remane ALL the files in the current directory that are 'visible' (filename not starting with a '.')

________________________________________
have a question concerning the renamining of multiple files in a folder. For about 200 files I would like to add the String "1_" to the beginning of all filenames. The filenames are for example "DATASET_X_Y_Z" and the result should be "1_DATASET_X_Y_Z". Maybe somebody knows how to do this the easy way. Unfortunately I don't know a thing about Shellscripting but maybe there is a oneliner for the terminal.

  • rename 's/^/1_/' * for renaming all files in the current directory

or

  • rename 's/^/1_/' DATASET* for renaming all files in the current directory starting with DATASET in their name

Explanation: the expression s/^/1_/ says: "replace the beginning of the filename (that means this symbol -> ^)' with 1_".


________________________________________

I have around 300 files named

some_name_123456789.zip
another-name2_987654321.zip
something(1)_123454321.zip
[2]something_987656789.zip

I need to rename them all to

ds_123456789.zip
ds_987654321.zip
ds_123454321.zip
ds_987656789.zip

How can i do this?

rename "s/.+_/ds/g" files

.+ represents everything up to (in this context) the last underscore (_) character (so this works with multiple underscores, as mentioned in your first example). This requires that there be at least one character before the underscore; if you might have file names like _20131012.zip, use .* instead. So this three-character string (.+_ or .*_) will match everything up to and including the last underscore in the filename. s/old/new/ means substitute the new string (ds) for the old string. The g means global and might not be necessary in this case.

To be sure that the regexp matches from the beginning I would rather put ^ to the beginning. Also OP wanted to retain the underscore. The g option at the end is not really needed here - it would match multiple instances in the file name if possible. So I think this command would perform better: 

rename "s/^.+_/ds_/" files


adding the g is just a standard habit from me and i agree that it's not needed in this case.

_________________________________________________________________________

For files handling in gnome you will have to use the graphical version of vim called gvim, to install it type sudo apt-get install vim-gnome.

Has an option you can create a .desktop file that will be listed on 'Open with other application' tab:

  • Navigate to ~/.local/share/applications
  • Create a file called vim-console.desktop with these contents:
[Desktop Entry]
Encoding=UTF-8
Name=Vim Text Editor (Console)
Comment=Edit text files in a console using Vim
Exec=gnome-terminal --full-screen --execute bash -c "vim %u"
Terminal=true
Type=Application
Icon=/usr/share/pixmaps/vim.svg
Categories=Application;Utility;TextEditor;
StartupNotify=true
MimeType=text/plain;
NoDisplay=true

After this you will see Vim Text Editor (Console) in your Open with other application tab, select it and when you double click the file you will be able to open it using vim terminal editor.



 




versió per imprimir